﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.RoboticOperationMerge.CUiROMMainForm
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using C1.Win.C1FlexGrid;
using C1.Win.C1FlexGrid.Util.BaseControls;
using EngineeringInternalExtension;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.Resources;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.PrivateImplementationDetails;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.RoboticOperationMerge;

public class CUiROMMainForm : TxForm
{
  private const string AUTOMATIC_MATCH_SETTINGS_RELATIVE_PATH = "AutomaticMatchSettings";
  private const string AUTOMATIC_MATCH_CRITERIA = "AutomaticMatchCriteria";
  private const string MATCH_BY_NAME = "MatchByName";
  private const string MATCH_BY_NAME_CASE_SENSITIVE = "MatchByNameCaseSensitive";
  private const string MATCH_BY_DISTANCE = "MatchByDistance";
  private const string MATCH_BY_DISTANCE_WITH_MAX_DEVIATION = "MatchByDistanceWithMaxDeviation";
  private const string AUTOMATIC_MATCH_MAX_DISTANCE = "AutomaticMatchMaxDistance";
  private const string MERGE_SETTINGS_RELATIVE_PATH = "MergeSettings";
  private const string COPY_DEFAULT_POSITION = "CopyDefaultPosition";
  private const string COPY_DEFAULT_ORIENTATION_ALL = "CopyDefaultOrientationAll";
  private const string COPY_DEFAULT_ORIENTATION_EXCEPT_PERPENDICULAR = "CopyDefaultOrientationExceptPerpendicular";
  private const string COPY_DEFAULT_EXTERNAL_AXIS = "CopyDefaultExternalAxis";
  private const string COPY_DEFAULT_TAUGHT = "CopyDefaultTaught";
  private const string COPY_DEFAULT_ROBOT_CONFIGURATION = "CopyDefaultRobotConfiguration";
  private const string COPY_DEFAULT_ROBOTIC_PARAMETERS = "CopyDefaultRoboticParameters";
  private const string COPY_DEFAULT_OLP_COMMANDS = "CopyDefaultOlpCommands";
  private const string COPY_DEFAULT_ATTRIBUTES = "CopyDefaultAttributes";
  private const string COPY_DEFAULT_NAME = "CopyDefaultName";
  private const string COPY_ALTERNATE_POSITION = "CopyAlternatePosition";
  private const string COPY_ALTERNATE_ORIENTATION_ALL = "CopyAlternateOrientationAll";
  private const string COPY_ALTERNATE_ORIENTATION_EXCEPT_PERPENDICULAR = "CopyAlternateOrientationExceptPerpendicular";
  private const string COPY_ALTERNATE_EXTERNAL_AXIS = "CopyAlternateExternalAxis";
  private const string COPY_ALTERNATE_TAUGHT = "CopyAlternateTaught";
  private const string COPY_ALTERNATE_ROBOT_CONFIGURATION = "CopyAlternateRobotConfiguration";
  private const string COPY_ALTERNATE_ROBOTIC_PARAMETERS = "CopyAlternateRoboticParameters";
  private const string COPY_ALTERNATE_OLP_COMMANDS = "CopyAlternateOlpCommands";
  private const string COPY_ALTERNATE_ATTRIBUTES = "CopyAlternateAttributes";
  private const string COPY_ALTERNATE_NAME = "CopyAlternateName";
  private const string COPY_VIA_POSITION = "CopyViaPosition";
  private const string COPY_VIA_ORIENTATION_ALL = "CopyViaOrientationAll";
  private const string COPY_VIA_EXTERNAL_AXIS = "CopyViaExternalAxis";
  private const string COPY_VIA_TAUGHT = "CopyViaTaught";
  private const string COPY_VIA_ROBOT_CONFIGURATION = "CopyViaRobotConfiguration";
  private const string COPY_VIA_ROBOTIC_PARAMETERS = "CopyViaRoboticParameters";
  private const string COPY_VIA_OLP_COMMANDS = "CopyViaOlpCommands";
  private const string COPY_VIA_ATTRIBUTES = "CopyViaAttributes";
  private const string COPY_VIA_NAME = "CopyViaName";
  private const string COPY_OPERATION_ROBOTIC_PARAMETERS = "CopyOperationRoboticParameters";
  private const string COPY_OPERATION_OLP_COMMANDS = "CopyOperationOlpCommands";
  private const string COPY_OPERATION_ATTRIBUTES = "CopyOperationAttributes";
  private const string COPY_OPERATION_NAME = "CopyOperationName";
  private const string AUTOMATIC_LOG_SETTINGS_RELATIVE_PATH = "AutomaticLogSettings";
  private const string SHOW_LOG_AUTOMATIC = "ShowLogAutomatic";
  private CCoROMRoboticOperationMergeCmd m_command;
  private CApROMDataManager m_dataManager;
  private CApROMObserverManager m_observerManager;
  private ITxObject m_targetOperation;
  private ITxObject m_sourceOperation;
  private List<ITxObject> m_emphasizedTargetLocations;
  private List<ITxObject> m_emphasizedMatchedLocations;
  private bool m_isEmphasizeMode;
  private bool m_areSettingsLoaded;
  private bool m_isTargetLocationChanged;
  private bool m_isInternalSelection;
  private CUiROMSelectOperationsForm m_selectOperationsForm;
  private bool m_acceptSelectedOperations;
  private ITxObject m_selectedSourceOperation;
  private ITxObject m_selectedTargetOperation;
  private CApROMMerger m_merger;
  private CUiROMAutomaticLogSettings m_automaticLogSettings;
  private bool m_useDefaultLocSelectOperationsDlg = true;
  private TxCompoundOperation weldContainer;
  private ITxObjectCollection m_weldLocationContainer;
  private IContainer components;
  private TxToolBarButton m_selectOperationsButton;
  private TxToolBarButton m_settingsButton;
  private ToolBarButton m_separator1;
  private TxToolBarButton m_automaticMatchButton;
  private TxToolBarButton m_matchButton;
  private TxToolBarButton m_alternativeMatchButton;
  private ToolBarButton m_separator2;
  private TxToolBarButton m_addLocationsBeforeButton;
  private TxToolBarButton m_addLocationsAfterButton;
  private TxToolBarButton m_emphasizePairButton;
  private TxToolBarButton m_unMatchButton;
  private TxToolBarButton m_deleteUnmatchedButton;
  private ToolBarButton m_separator3;
  private TxToolBarButton m_moveLocationsUpButton;
  private TxToolBarButton m_moveLocationsDownButton;
  private TxToolBarButton m_reverseButton;
  private TxToolBarButton m_reorderButton;
  private TxToolBarButton m_removeFromTargetButton;
  private ToolBarButton m_separator4;
  private TxToolBarButton m_selectAllButton;
  private TxToolBarButton m_unselectAllButton;
  private TxButton m_executeButton;
  private TxButton m_resetButton;
  private TxButton m_closeButton;
  private CUiROMRoboticOperationGridWrapper m_targetOperationGrid;
  private CUiROMRoboticOperationGridWrapper m_sourceOperationGrid;
  private Panel panel1;
  private Panel panel2;
  private Panel panel3;
  private Splitter splitter1;
  private TxContextMenuStrip contextMenuStrip1;
  private TxToolStripMenuItem defulatToolStripMenuItem;
  private TxToolStripMenuItem defaultToolStripMenuItem;
  private TxToolStripMenuItem alternateToolStripMenuItem1;
  private TxToolBarButton m_replaceEmptyTarget;
  private TxButton m_previewButton;
  private TxToolBar m_mainFormToolbar;

  public CUiROMMainForm(CCoROMRoboticOperationMergeCmd command)
  {
    this.InitializeComponent();
    ((Control) this).Visible = false;
    this.m_command = command;
    this.m_targetOperation = (ITxObject) null;
    this.m_sourceOperation = (ITxObject) null;
    this.m_dataManager = new CApROMDataManager();
    this.m_observerManager = new CApROMObserverManager();
    this.m_automaticLogSettings = new CUiROMAutomaticLogSettings();
    this.m_emphasizedTargetLocations = new List<ITxObject>();
    this.m_emphasizedMatchedLocations = new List<ITxObject>();
    this.m_isEmphasizeMode = ((ToolBarButton) this.m_emphasizePairButton).Pushed;
    this.LoadSettings();
    this.InitColumns();
    this.UpdateTargetDistanceColumnCaption(TxApplication.Options.Units.LinearUnitName);
    this.RunSelectOperations();
  }

  public virtual void OnInitTxForm()
  {
    this.RegisterForEvents();
    try
    {
      this.m_targetOperationGrid.LinearDigitsAfterDecimalPoint = TxApplication.Options.Units.LinearDigitsAfterDecimalPoint;
      this.m_targetOperationGrid.LinearMultiplier = TxApplication.Options.Units.LinearMultiplier;
    }
    catch
    {
    }
    this.InitGrids();
  }

  private void RegisterForEvents()
  {
    this.RegisterSelectionEvents();
    this.m_targetOperationGrid.TreeSelectionChanged += new TreeSelectionChangedEventHandler(this.m_targetOperationGrid_TreeSelectionChanged);
    ((C1FlexGridBase) this.m_targetOperationGrid).AfterEdit += new RowColEventHandler(this.m_targetOperationGrid_AfterEdit);
    this.m_sourceOperationGrid.TreeSelectionChanged += new TreeSelectionChangedEventHandler(this.m_sourceOperationGrid_TreeSelectionChanged);
    this.m_observerManager.OnObservedObjectChanged += new ObservedObjectChangedEventHandler(this.m_observerManager_OnObservedObjectChanged);
    TxApplication.Options.Units.LinearUnitsChanged += new TxUnitsOptions_LinearUnitsChangedEventHandler(this.Units_LinearUnitsChanged);
    TxApplication.ApplicationEvents.Exiting += new TxApplication_ExitingEventHandler(this.ApplicationEvents_Exiting);
  }

  private void UnRegisterForEvents()
  {
    this.UnRegisterSelectionEvents();
    this.m_targetOperationGrid.TreeSelectionChanged -= new TreeSelectionChangedEventHandler(this.m_targetOperationGrid_TreeSelectionChanged);
    ((C1FlexGridBase) this.m_targetOperationGrid).AfterEdit -= new RowColEventHandler(this.m_targetOperationGrid_AfterEdit);
    this.m_sourceOperationGrid.TreeSelectionChanged -= new TreeSelectionChangedEventHandler(this.m_sourceOperationGrid_TreeSelectionChanged);
    this.m_observerManager.OnObservedObjectChanged -= new ObservedObjectChangedEventHandler(this.m_observerManager_OnObservedObjectChanged);
    this.m_observerManager.UnRegisterObservedObjects();
    if (this.m_selectOperationsForm != null)
    {
      try
      {
        ((Component) this.m_selectOperationsForm).Disposed -= new EventHandler(this.m_selectOperationsForm_Disposed);
        ((Form) this.m_selectOperationsForm).FormClosed -= new FormClosedEventHandler(this.m_selectOperationsForm_FormClosed);
        ((Form) this.m_selectOperationsForm).Close();
        this.m_selectOperationsForm = (CUiROMSelectOperationsForm) null;
      }
      catch (Exception ex)
      {
      }
    }
    TxApplication.Options.Units.LinearUnitsChanged -= new TxUnitsOptions_LinearUnitsChangedEventHandler(this.Units_LinearUnitsChanged);
    TxApplication.ApplicationEvents.Exiting -= new TxApplication_ExitingEventHandler(this.ApplicationEvents_Exiting);
  }

  protected virtual void OnClosing(CancelEventArgs e)
  {
    this.UnRegisterForEvents();
    this.StoreSettings();
    this.ClearAllEmphasizedPairs(true);
    this.m_merger = (CApROMMerger) null;
    GC.Collect();
    GC.WaitForPendingFinalizers();
    GC.Collect();
    base.OnClosing(e);
  }

  protected virtual void OnKeyDown(KeyEventArgs e)
  {
    if (e.KeyCode == Keys.Delete && e.Modifiers == Keys.None && ((ToolBarButton) this.m_removeFromTargetButton).Enabled)
    {
      this.RunRemoveFromTarget();
      this.UpdateAllButtonEnablers();
    }
    base.OnKeyDown(e);
  }

  private void ApplicationEvents_Exiting(object sender, TxApplication_ExitingEventArgs args)
  {
    ((Form) this).Close();
  }

  private void Units_LinearUnitsChanged(object sender, TxUnitsOptions_LinearUnitsChangedEventArgs e)
  {
    string linearUnitName = TxApplication.Options.Units.LinearUnitName;
    double linearMultiplier = TxApplication.Options.Units.LinearMultiplier;
    int afterDecimalPoint = TxApplication.Options.Units.LinearDigitsAfterDecimalPoint;
    this.UpdateTargetDistanceColumnCaption(linearUnitName);
    this.m_targetOperationGrid.LinearMultiplier = linearMultiplier;
    this.m_targetOperationGrid.LinearDigitsAfterDecimalPoint = afterDecimalPoint;
    this.m_targetOperationGrid.UpdateLinearColumns(2, ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count - 2);
  }

  private void InitGrids()
  {
    if (this.m_isEmphasizeMode)
      this.ClearAllEmphasizedPairs(true);
    this.m_isTargetLocationChanged = false;
    this.ResetTargetGridData();
    this.ResetSourceGridData();
    this.UpdateAllButtonEnablers();
    this.RegisterTargetGridObjects();
    this.RegisterSourceGridObjects();
  }

  private void ResetTargetGridData()
  {
    this.m_dataManager.RecreateTargetOperationUiData(this.m_targetOperation, this.m_sourceOperation);
    ArrayList nodeInfoList = new ArrayList();
    CUiROMRoboticTargetOperationInfo targetOperation = this.m_dataManager.TargetOperation;
    if (targetOperation != null && targetOperation.NodeObject != null)
    {
      nodeInfoList.Add((object) targetOperation);
      List<CUiROMTargetInfo> targetChildren = this.m_dataManager.TargetChildren;
      if (targetChildren != null && targetChildren.Count > 0)
      {
        foreach (CUiROMTargetInfo cuiRomTargetInfo in targetChildren)
          nodeInfoList.Add((object) cuiRomTargetInfo);
      }
    }
    this.m_targetOperationGrid.InitGrid(nodeInfoList);
  }

  private void ResetSourceGridData()
  {
    this.m_dataManager.RecreateSourceOperationUiData(this.m_sourceOperation);
    ArrayList nodeInfoList = new ArrayList();
    CUiROMRoboticSourceOperationInfo sourceOperation = this.m_dataManager.SourceOperation;
    if (sourceOperation != null && sourceOperation.NodeObject != null)
    {
      nodeInfoList.Add((object) sourceOperation);
      List<CUiROMSourceInfo> sourceChildren = this.m_dataManager.SourceChildren;
      if (sourceChildren != null && sourceChildren.Count > 0)
      {
        foreach (CUiROMSourceInfo cuiRomSourceInfo in sourceChildren)
          nodeInfoList.Add((object) cuiRomSourceInfo);
      }
    }
    this.m_sourceOperationGrid.InitGrid(nodeInfoList);
  }

  private void InitColumns()
  {
    ((C1FlexGridBase) this.m_targetOperationGrid).Cols[0].Name = "TargetOperation";
    ((C1FlexGridBase) this.m_targetOperationGrid).Cols[1].Name = "Match";
    ((C1FlexGridBase) this.m_targetOperationGrid).Cols[2].Name = "Distance";
    ((C1FlexGridBase) this.m_targetOperationGrid).Cols[3].Name = "MergeSchema";
    ((C1FlexGridBase) this.m_targetOperationGrid).Cols[4].Name = "Merge";
    this.m_targetOperationGrid.AddColumnCustomNormalStyle(((C1FlexGridBase) this.m_targetOperationGrid).Cols[1].Name, "matchColumnNormalStyle");
    this.m_targetOperationGrid.AddColumnCustomSelectionStyle(((C1FlexGridBase) this.m_targetOperationGrid).Cols[1].Name, "matchColumnSelectStyle");
    this.m_targetOperationGrid.AddColumnCustomNormalStyle(((C1FlexGridBase) this.m_targetOperationGrid).Cols[2].Name, "distanceColumnNormalStyle");
    this.m_targetOperationGrid.AddColumnCustomSelectionStyle(((C1FlexGridBase) this.m_targetOperationGrid).Cols[2].Name, "distanceColumnSelectStyle");
    this.m_targetOperationGrid.AddColumnCustomNormalStyle(((C1FlexGridBase) this.m_targetOperationGrid).Cols[3].Name, "mergeColumnNormalStyle");
    this.m_targetOperationGrid.AddColumnCustomSelectionStyle(((C1FlexGridBase) this.m_targetOperationGrid).Cols[3].Name, "mergeColumnSelectStyle");
    this.m_targetOperationGrid.AddColumnCustomNormalStyle(((C1FlexGridBase) this.m_targetOperationGrid).Cols[4].Name, "mergeColumnNormalStyle");
    this.m_targetOperationGrid.AddColumnCustomSelectionStyle(((C1FlexGridBase) this.m_targetOperationGrid).Cols[4].Name, "mergeColumnSelectStyle");
    ((C1FlexGridBase) this.m_sourceOperationGrid).Cols[0].Name = "SourceOperation";
  }

  private void RefreshTargetLocationsPositions()
  {
    List<CUiROMTargetInfo> cuiRomTargetInfoList = new List<CUiROMTargetInfo>();
    for (int index = 2; index < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count; ++index)
    {
      Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[index].Node;
      if (node != null && node.Key is CUiROMTargetInfo key)
        cuiRomTargetInfoList.Add(key);
    }
    this.m_dataManager.TargetChildren = cuiRomTargetInfoList;
  }

  private void UpdateAllButtonEnablers()
  {
    ((ToolBarButton) this.m_settingsButton).Enabled = true;
    ((ToolBarButton) this.m_selectOperationsButton).Enabled = this.m_selectOperationsForm == null;
    if (this.m_sourceOperation != null && this.m_targetOperation != null)
    {
      ((ToolBarButton) this.m_automaticMatchButton).Enabled = this.AutomaticMatchButtonEnabler();
      ((ToolBarButton) this.m_matchButton).Enabled = this.MatchButtonEnabler();
      ((ToolBarButton) this.m_alternativeMatchButton).Enabled = this.AlternativeMatchButtonEnabler();
      ((ToolBarButton) this.m_addLocationsBeforeButton).Enabled = this.AddLocationsBeforeButtonEnabler();
      ((ToolBarButton) this.m_addLocationsAfterButton).Enabled = this.AddLocationsAfterButtonEnabler();
      ((ToolBarButton) this.m_emphasizePairButton).Enabled = this.EmphasizePairButtonEnabler();
      ((ToolBarButton) this.m_unMatchButton).Enabled = this.UnMatchButtonEnabler();
      ((ToolBarButton) this.m_deleteUnmatchedButton).Enabled = this.DeleteUnmatchedButtonEnabler();
      ((ToolBarButton) this.m_moveLocationsUpButton).Enabled = this.MoveLocationsUpButtonEnabler();
      ((ToolBarButton) this.m_moveLocationsDownButton).Enabled = this.MoveLocationsDownButtonEnabler();
      ((ToolBarButton) this.m_reverseButton).Enabled = this.ReverseButtonEnabler();
      ((ToolBarButton) this.m_reorderButton).Enabled = this.ReorderButtonEnabler();
      ((ToolBarButton) this.m_removeFromTargetButton).Enabled = this.RemoveFromTargetButtonEnabler();
      ((ToolBarButton) this.m_selectAllButton).Enabled = this.SelectAllButtonEnabler();
      ((ToolBarButton) this.m_unselectAllButton).Enabled = this.UnselectAllButtonEnabler();
      ((ToolBarButton) this.m_replaceEmptyTarget).Enabled = this.ReplaceEmptyTargetEnabler();
      ((Control) this.m_executeButton).Enabled = this.ExecuteButtonEnabler();
      ((Control) this.m_previewButton).Enabled = this.IsAnyMergeMarked();
      ((Control) this.m_resetButton).Enabled = true;
    }
    else
    {
      ((ToolBarButton) this.m_automaticMatchButton).Enabled = false;
      ((ToolBarButton) this.m_matchButton).Enabled = false;
      ((ToolBarButton) this.m_alternativeMatchButton).Enabled = false;
      ((ToolBarButton) this.m_addLocationsBeforeButton).Enabled = false;
      ((ToolBarButton) this.m_addLocationsAfterButton).Enabled = false;
      ((ToolBarButton) this.m_emphasizePairButton).Enabled = false;
      ((ToolBarButton) this.m_unMatchButton).Enabled = false;
      ((ToolBarButton) this.m_deleteUnmatchedButton).Enabled = false;
      ((ToolBarButton) this.m_moveLocationsUpButton).Enabled = false;
      ((ToolBarButton) this.m_moveLocationsDownButton).Enabled = false;
      ((ToolBarButton) this.m_reverseButton).Enabled = false;
      ((ToolBarButton) this.m_reorderButton).Enabled = false;
      ((ToolBarButton) this.m_removeFromTargetButton).Enabled = false;
      ((ToolBarButton) this.m_selectAllButton).Enabled = false;
      ((ToolBarButton) this.m_unselectAllButton).Enabled = false;
      ((ToolBarButton) this.m_replaceEmptyTarget).Enabled = false;
      ((Control) this.m_executeButton).Enabled = false;
      ((Control) this.m_previewButton).Enabled = false;
      ((Control) this.m_resetButton).Enabled = false;
    }
  }

  private void SetAllButtonsEnableState(bool state)
  {
    ((ToolBarButton) this.m_settingsButton).Enabled = state;
    ((ToolBarButton) this.m_selectOperationsButton).Enabled = state;
    ((ToolBarButton) this.m_automaticMatchButton).Enabled = state;
    ((ToolBarButton) this.m_matchButton).Enabled = state;
    ((ToolBarButton) this.m_alternativeMatchButton).Enabled = state;
    ((ToolBarButton) this.m_addLocationsBeforeButton).Enabled = state;
    ((ToolBarButton) this.m_addLocationsAfterButton).Enabled = state;
    ((ToolBarButton) this.m_emphasizePairButton).Enabled = state;
    ((ToolBarButton) this.m_unMatchButton).Enabled = state;
    ((ToolBarButton) this.m_deleteUnmatchedButton).Enabled = state;
    ((ToolBarButton) this.m_moveLocationsUpButton).Enabled = state;
    ((ToolBarButton) this.m_moveLocationsDownButton).Enabled = state;
    ((ToolBarButton) this.m_reverseButton).Enabled = state;
    ((ToolBarButton) this.m_reorderButton).Enabled = state;
    ((ToolBarButton) this.m_removeFromTargetButton).Enabled = state;
    ((ToolBarButton) this.m_selectAllButton).Enabled = state;
    ((ToolBarButton) this.m_unselectAllButton).Enabled = state;
    ((ToolBarButton) this.m_replaceEmptyTarget).Enabled = state;
    ((Control) this.m_executeButton).Enabled = state;
    ((Control) this.m_previewButton).Enabled = state;
    ((Control) this.m_resetButton).Enabled = state;
  }

  private void UpdateOnOperationsButtonEnablers()
  {
    ((ToolBarButton) this.m_automaticMatchButton).Enabled = this.AutomaticMatchButtonEnabler();
    ((ToolBarButton) this.m_selectAllButton).Enabled = this.SelectAllButtonEnabler();
    ((ToolBarButton) this.m_unselectAllButton).Enabled = this.UnselectAllButtonEnabler();
    ((Control) this.m_executeButton).Enabled = this.ExecuteButtonEnabler();
    ((Control) this.m_previewButton).Enabled = this.IsAnyMergeMarked();
    ((Control) this.m_resetButton).Enabled = true;
  }

  private void UpdateOnSelectionButtonEnablers()
  {
    ((ToolBarButton) this.m_matchButton).Enabled = this.MatchButtonEnabler();
    ((ToolBarButton) this.m_alternativeMatchButton).Enabled = this.AlternativeMatchButtonEnabler();
    ((ToolBarButton) this.m_addLocationsBeforeButton).Enabled = this.AddLocationsBeforeButtonEnabler();
    ((ToolBarButton) this.m_addLocationsAfterButton).Enabled = this.AddLocationsAfterButtonEnabler();
    ((ToolBarButton) this.m_emphasizePairButton).Enabled = this.EmphasizePairButtonEnabler();
    ((ToolBarButton) this.m_unMatchButton).Enabled = this.UnMatchButtonEnabler();
    ((ToolBarButton) this.m_deleteUnmatchedButton).Enabled = this.DeleteUnmatchedButtonEnabler();
    ((ToolBarButton) this.m_moveLocationsUpButton).Enabled = this.MoveLocationsUpButtonEnabler();
    ((ToolBarButton) this.m_moveLocationsDownButton).Enabled = this.MoveLocationsDownButtonEnabler();
    ((ToolBarButton) this.m_reverseButton).Enabled = this.ReverseButtonEnabler();
    ((ToolBarButton) this.m_reorderButton).Enabled = this.ReorderButtonEnabler();
    ((ToolBarButton) this.m_removeFromTargetButton).Enabled = this.RemoveFromTargetButtonEnabler();
    ((ToolBarButton) this.m_replaceEmptyTarget).Enabled = this.ReplaceEmptyTargetEnabler();
  }

  private bool ExecuteButtonEnabler() => this.m_isTargetLocationChanged || this.IsAnyMergeMarked();

  private bool IsAnyMergeMarked()
  {
    bool flag = this.m_targetOperationGrid.IsMergeColumnChecked(1);
    if (!flag)
    {
      for (int row = 2; row < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count; ++row)
      {
        Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[row].Node;
        if (node != null && node.Key is CUiROMTargetInfo key && (!key.BelongToTarget || key.MatchedObject != null && this.m_targetOperationGrid.IsMergeColumnChecked(row)))
        {
          flag = true;
          break;
        }
      }
    }
    return flag;
  }

  private bool AutomaticMatchButtonEnabler()
  {
    bool flag = false;
    if (this.m_dataManager.TargetChildren.Count > 0 && this.m_dataManager.SourceChildren.Count > 0)
      flag = true;
    return flag;
  }

  private bool MatchButtonEnabler()
  {
    bool flag = false;
    if (this.m_targetOperationGrid.SelectedTreeRows.Count >= 1 && this.m_sourceOperationGrid.SelectedTreeRows.Count == 1 && !this.m_targetOperationGrid.SelectedTreeRows.Contains(1) && !this.m_sourceOperationGrid.SelectedTreeRows.Contains(1))
    {
      int selectedTreeRow = this.m_sourceOperationGrid.SelectedTreeRows[0];
      if (selectedTreeRow > 1 && selectedTreeRow < ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count)
      {
        Node node1 = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[selectedTreeRow].Node;
        if (node1 != null && node1.Key is CUiROMSourceInfo key1 && key1.NodeObject != null)
        {
          List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
          int count = ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count;
          foreach (int num in selectedTreeRows)
          {
            if (num > 1 && num < count)
            {
              Node node2 = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[num].Node;
              if (node2 != null && node2.Key is CUiROMTargetInfo key && key.BelongToTarget && key.NodeObject != null && this.m_dataManager.AreObjectsCompatible(key.NodeObject, key1.NodeObject))
              {
                flag = true;
                break;
              }
            }
          }
        }
      }
    }
    return flag;
  }

  private bool AlternativeMatchButtonEnabler()
  {
    bool flag = false;
    if (this.m_targetOperationGrid.SelectedTreeRows.Count >= 1 && this.m_sourceOperationGrid.SelectedTreeRows.Count == 1 && !this.m_targetOperationGrid.SelectedTreeRows.Contains(1) && !this.m_sourceOperationGrid.SelectedTreeRows.Contains(1))
    {
      int selectedTreeRow = this.m_sourceOperationGrid.SelectedTreeRows[0];
      if (selectedTreeRow > 1 && selectedTreeRow < ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count)
      {
        Node node1 = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[selectedTreeRow].Node;
        if (node1 != null && node1.Key is CUiROMSourceInfo key1 && key1.NodeObject != null)
        {
          List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
          int count = ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count;
          foreach (int index in selectedTreeRows)
          {
            if (index > 1 && index < count && !this.IsNodeOfTypeViaLocation(index) && !this.IsNodeOfTypeOperation(index))
            {
              Node node2 = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[index].Node;
              if (node2 != null && node2.Key is CUiROMTargetInfo key && key.BelongToTarget && key.NodeObject != null && this.m_dataManager.AreObjectsCompatible(key.NodeObject, key1.NodeObject))
              {
                flag = true;
                break;
              }
            }
          }
        }
      }
    }
    return flag;
  }

  private bool AddLocationsBeforeButtonEnabler()
  {
    bool flag = false;
    if (this.m_targetOperationGrid.SelectedTreeRows.Count == 1 && this.m_sourceOperationGrid.SelectedTreeRows.Count >= 1 && !this.m_targetOperationGrid.SelectedTreeRows.Contains(1) && !this.m_sourceOperationGrid.SelectedTreeRows.Contains(1))
    {
      flag = true;
      if (this.m_targetOperation is ITxContinuousOperation)
        flag = this.IsSelectionValidForInsertToContOp();
    }
    return flag;
  }

  private bool IsSelectionValidForInsertToContOp()
  {
    bool contOp = true;
    bool flag1 = false;
    bool flag2 = false;
    foreach (int selectedTreeRow in this.m_sourceOperationGrid.SelectedTreeRows)
    {
      if (this.IsSourceNodeOfTypeOperation(selectedTreeRow) || this.IsSourceNodeEmpty(selectedTreeRow))
      {
        contOp = false;
        break;
      }
      if (this.IsSourceNodeOfTypeViaLocation(selectedTreeRow))
        flag2 = true;
      else if (this.IsSourceNodeOfTypeSeamLocation(selectedTreeRow))
        flag1 = true;
    }
    if (flag2 & flag1)
      contOp = false;
    if (!flag2 && !flag1)
      contOp = false;
    List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
    if (flag2)
    {
      if (!this.IsNodeOfTypeViaLocation(selectedTreeRows[0]) && !this.IsNodeOfTypeSeamOperation(selectedTreeRows[0]))
        contOp = false;
    }
    else if (!this.IsNodeOfTypeSeamLocation(selectedTreeRows[0]))
      contOp = false;
    return contOp;
  }

  private bool AddLocationsAfterButtonEnabler()
  {
    bool flag = false;
    if (this.m_targetOperationGrid.SelectedTreeRows.Count == 1 && this.m_sourceOperationGrid.SelectedTreeRows.Count >= 1 && !this.m_sourceOperationGrid.SelectedTreeRows.Contains(1))
    {
      flag = true;
      if (this.m_targetOperation is ITxContinuousOperation)
        flag = this.IsSelectionValidForInsertToContOp();
    }
    return flag;
  }

  private bool EmphasizePairButtonEnabler() => true;

  private bool UnMatchButtonEnabler()
  {
    bool flag = false;
    if (this.m_targetOperationGrid.SelectedTreeRows.Count >= 1 && !this.m_targetOperationGrid.SelectedTreeRows.Contains(1))
    {
      List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
      int count = ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count;
      foreach (int num in selectedTreeRows)
      {
        if (num >= 0 && num < count)
        {
          Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[num].Node;
          if (node != null && node.Key is CUiROMTargetInfo key && key.BelongToTarget && key.MatchedObject != null)
          {
            flag = true;
            break;
          }
        }
      }
    }
    return flag;
  }

  private bool DeleteUnmatchedButtonEnabler()
  {
    bool flag = false;
    if (((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count > 2)
      flag = true;
    return flag;
  }

  private bool MoveLocationsUpButtonEnabler()
  {
    bool flag = false;
    if (this.m_targetOperationGrid.SelectedTreeRows.Count >= 1 && !this.m_targetOperationGrid.SelectedTreeRows.Contains(1) && !this.m_targetOperationGrid.SelectedTreeRows.Contains(2))
      flag = !(this.m_targetOperation is ITxContinuousOperation) ? !(this.m_targetOperation is TxRoboticSeamOperation) : this.MoveUpCheckContOp();
    return flag;
  }

  private bool MoveUpCheckContOp()
  {
    bool flag = true;
    List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
    List<int> intList = new List<int>((IEnumerable<int>) this.m_targetOperationGrid.SelectedTreeRows);
    foreach (int num in selectedTreeRows)
    {
      if (flag && num > 1 && num < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count && this.IsNodeOfTypeSeamLocation(num))
      {
        int indexOfSeamOperation = this.GetIndexOfSeamOperation(num);
        if (selectedTreeRows.Contains(indexOfSeamOperation))
          intList.Remove(num);
      }
    }
    foreach (int index in intList)
    {
      if (flag && index > 1 && index < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count)
        flag = this.CanNodeBeMovedUpInContOp(index);
    }
    return flag;
  }

  private bool MoveLocationsDownButtonEnabler()
  {
    bool flag = false;
    if (this.m_targetOperationGrid.SelectedTreeRows.Count >= 1 && !this.m_targetOperationGrid.SelectedTreeRows.Contains(1) && !this.m_targetOperationGrid.SelectedTreeRows.Contains(((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count - 1))
      flag = !(this.m_targetOperation is ITxContinuousOperation) ? !(this.m_targetOperation is TxRoboticSeamOperation) : this.MoveDownCheckContOp();
    return flag;
  }

  private bool ReverseButtonEnabler()
  {
    bool flag = false;
    List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
    if (selectedTreeRows.Count == 0)
      flag = false;
    else if (selectedTreeRows.Count == 1)
    {
      Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[selectedTreeRows[0]].Node;
      CUiROMGridNodeInfo key = node.Key as CUiROMGridNodeInfo;
      if (node != null && key.NodeObject is ITxRoboticOperation)
        flag = CUiROMMainForm.IsNotEmptyOperation(node);
    }
    else if (selectedTreeRows.Count == 2)
    {
      Node node1 = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[selectedTreeRows[0]].Node;
      Node node2 = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[selectedTreeRows[1]].Node;
      CUiROMGridNodeInfo key1 = node1.Key as CUiROMGridNodeInfo;
      CUiROMGridNodeInfo key2 = node2.Key as CUiROMGridNodeInfo;
      if ((node1 != null || node2 == null) && (key1.NodeObject is TxRoboticSeamOperation && CUiROMMainForm.IsNotEmptyOperation(node1) || key1.NodeObject is ITxRoboticLocationOperation) && (key2.NodeObject is TxRoboticSeamOperation && CUiROMMainForm.IsNotEmptyOperation(node2) || key2.NodeObject is ITxRoboticLocationOperation) && ((ITxObject) (key1.NodeObject as ITxRoboticOperation)).Collection == ((ITxObject) (key2.NodeObject as ITxRoboticOperation)).Collection)
        flag = true;
    }
    return flag;
  }

  private static bool IsNotEmptyOperation(Node currentNode)
  {
    bool flag = false;
    ITxObject nodeObject = (currentNode.Key as CUiROMGridNodeInfo).NodeObject;
    if (nodeObject is ITxOrderedCompoundOperation)
    {
      TxObjectList directDescendants = ((ITxObjectCollection) (nodeObject as ITxOrderedCompoundOperation)).GetDirectDescendants((ITxTypeFilter) new TxTypeFilter(typeof (ITxObject)));
      if (directDescendants != null && ((Collection<ITxObject>) directDescendants).Count > 0)
        flag = true;
    }
    return flag;
  }

  private bool ReorderButtonEnabler()
  {
    bool flag = false;
    if (this.m_targetOperation is ITxWeldOperation && this.AtLeastOneLocIsMatched())
      flag = true;
    return flag;
  }

  private bool MoveDownCheckContOp()
  {
    bool flag = true;
    List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
    List<int> intList = new List<int>((IEnumerable<int>) this.m_targetOperationGrid.SelectedTreeRows);
    foreach (int num in selectedTreeRows)
    {
      if (flag && num > 1 && num < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count && this.IsNodeOfTypeSeamLocation(num))
      {
        int indexOfSeamOperation = this.GetIndexOfSeamOperation(num);
        if (selectedTreeRows.Contains(indexOfSeamOperation))
          intList.Remove(num);
      }
    }
    foreach (int index in intList)
    {
      if (flag && index > 1 && index < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count)
        flag = this.CanNodeBeMovedDownInContOp(index);
    }
    return flag;
  }

  private bool RemoveFromTargetButtonEnabler()
  {
    bool flag = false;
    if (this.m_targetOperationGrid.SelectedTreeRows.Count >= 1 && !this.m_targetOperationGrid.SelectedTreeRows.Contains(1))
      flag = true;
    return flag;
  }

  private bool SelectAllButtonEnabler()
  {
    bool flag = false;
    if (((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count > 2)
      flag = true;
    return flag;
  }

  private bool UnselectAllButtonEnabler()
  {
    bool flag = false;
    if (((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count > 2)
      flag = true;
    return flag;
  }

  private bool ReplaceEmptyTargetEnabler()
  {
    bool flag = false;
    if (this.m_targetOperationGrid.SelectedTreeRows.Count == 1 && this.m_sourceOperationGrid.SelectedTreeRows.Count == 1 && (((C1FlexGridBase) this.m_targetOperationGrid).Rows[this.m_targetOperationGrid.SelectedTreeRows[0]].Node.Key as CUiROMGridNodeInfo).NodeType == CUiROMDataUtils.NodeType.NotSet && (((C1FlexGridBase) this.m_sourceOperationGrid).Rows[this.m_sourceOperationGrid.SelectedTreeRows[0]].Node.Key as CUiROMGridNodeInfo).NodeObject is ITxRoboticLocationOperation)
      flag = true;
    return flag;
  }

  private bool RunMerge(bool isPreview = false)
  {
    bool flag1 = true;
    if (!isPreview)
    {
      if (this.m_isEmphasizeMode)
        this.ClearAllEmphasizedPairs(true);
      this.m_observerManager.UnRegisterObservedObjects();
      GC.Collect();
      GC.WaitForPendingFinalizers();
      GC.Collect();
    }
    this.m_merger = (CApROMMerger) null;
    try
    {
      this.m_merger = new CApROMMerger(isPreview);
      List<CApROMMergeInfo> capRomMergeInfoList = new List<CApROMMergeInfo>();
      TxObjectList removedLocations = new TxObjectList();
      if (this.m_targetOperation is ITxObjectCollection targetOperation)
      {
        TxTypeFilter txTypeFilter = new TxTypeFilter();
        txTypeFilter.AddIncludedType(typeof (ITxLocatableObject));
        txTypeFilter.AddIncludedType(typeof (TxRoboticSeamOperation));
        removedLocations = targetOperation.GetAllDescendants((ITxTypeFilter) txTypeFilter) ?? new TxObjectList();
      }
      bool flag2 = false;
      CApROMMergeInfo capRomMergeInfo1 = new CApROMMergeInfo(this.m_targetOperation as ITxRoboticOperation, (ITxRoboticOperation) null, CUiROMDataUtils.MergeSchema.Operation);
      if (((C1FlexGridBase) this.m_targetOperationGrid).Cols.Contains("Merge") && ((C1FlexGridBase) this.m_targetOperationGrid).GetCellCheck(1, ((RowCol) ((C1FlexGridBase) this.m_targetOperationGrid).Cols["Merge"]).Index) == 1)
      {
        capRomMergeInfo1.MatchedObject = this.m_sourceOperation as ITxRoboticOperation;
        capRomMergeInfo1.MergeSchema = this.GetMergeSchemaAtRow(1);
        flag2 = true;
      }
      capRomMergeInfoList.Add(capRomMergeInfo1);
      for (int index = 2; index < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count; ++index)
      {
        Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[index].Node;
        if (node != null && node.Key is CUiROMTargetInfo key)
        {
          CApROMMergeInfo capRomMergeInfo2 = new CApROMMergeInfo((ITxRoboticOperation) null, (ITxRoboticOperation) null, this.GetMergeSchemaAtRow(index));
          if (key.BelongToTarget)
          {
            capRomMergeInfo2.TargetObject = key.NodeObject as ITxRoboticOperation;
            if (key.ShouldMerge && key.MatchedObject != null)
            {
              capRomMergeInfo2.MatchedObject = key.MatchedObject as ITxRoboticOperation;
              flag2 = true;
            }
          }
          else
          {
            capRomMergeInfo2.TargetObject = (ITxRoboticOperation) null;
            if (key.MatchedObject != null)
            {
              capRomMergeInfo2.MatchedObject = key.MatchedObject as ITxRoboticOperation;
              capRomMergeInfo2.MergeSchema = !this.IsNodeOfTypeViaLocation(index) ? CUiROMDataUtils.MergeSchema.LocDefault : CUiROMDataUtils.MergeSchema.Via;
              flag2 = true;
            }
          }
          if (capRomMergeInfo2.TargetObject != null || capRomMergeInfo2.MatchedObject != null)
          {
            capRomMergeInfoList.Add(capRomMergeInfo2);
            if (capRomMergeInfo2.TargetObject != null && ((Collection<ITxObject>) removedLocations).Contains((ITxObject) capRomMergeInfo2.TargetObject))
              ((Collection<ITxObject>) removedLocations).Remove((ITxObject) capRomMergeInfo2.TargetObject);
          }
        }
      }
      CApROMMergeInfo[] array = capRomMergeInfoList.ToArray();
      if (!isPreview)
        TxApplicationEx.FireDocumentUpdateStarted();
      this.m_merger.Merge(this.m_targetOperation as ITxOrderedObjectCollection, removedLocations, array, this.m_weldLocationContainer);
      if (!isPreview)
      {
        TxApplicationEx.FireDocumentUpdateEnded();
        this.InitGrids();
      }
      if (flag2)
      {
        bool flag3 = this.m_automaticLogSettings.ShowLogAutomatic | isPreview;
        if (!flag3 && TxAssemblyInfoEx.IsExcelInstalled(false, ""))
        {
          bool confirmed = false;
          if (this.AskAboutExcelLog(out confirmed) & confirmed)
          {
            if (TxAssemblyInfoEx.IsExcelInstalled(true, ""))
              flag3 = true;
          }
          else
            this.m_merger.KillExcel();
        }
        if (flag3)
          this.m_merger.ShowExcel();
      }
      this.m_merger = (CApROMMerger) null;
      GC.Collect();
      GC.WaitForPendingFinalizers();
      GC.Collect();
      TxApplication.RefreshDisplay();
    }
    catch (Exception ex)
    {
      this.m_merger?.RestoreCultureThread();
      this.m_merger = (CApROMMerger) null;
      GC.Collect();
      GC.WaitForPendingFinalizers();
      GC.Collect();
      TxApplication.RefreshDisplay();
      this.InitGrids();
    }
    return flag1;
  }

  private bool RunReset()
  {
    bool flag = true;
    if (TxMessageBox.Show(this.GetResourceManager().GetString("WARNING_RESET"), this.GetResourceManager().GetString("WARNING_CAPTION"), MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
      this.InitGrids();
    return flag;
  }

  private bool RunSelectOperations()
  {
    bool flag = true;
    try
    {
      if (this.m_selectOperationsForm == null)
      {
        this.m_acceptSelectedOperations = false;
        this.m_selectedSourceOperation = (ITxObject) null;
        this.m_selectedTargetOperation = (ITxObject) null;
        this.m_selectOperationsForm = new CUiROMSelectOperationsForm();
        if (this.m_selectOperationsForm != null)
        {
          ((Form) this.m_selectOperationsForm).FormClosed += new FormClosedEventHandler(this.m_selectOperationsForm_FormClosed);
          ((Component) this.m_selectOperationsForm).Disposed += new EventHandler(this.m_selectOperationsForm_Disposed);
          if (!this.m_areSettingsLoaded && this.m_useDefaultLocSelectOperationsDlg)
          {
            this.m_selectOperationsForm.DefaultLocation = ((Control) this).PointToScreen(((Control) this.m_mainFormToolbar).Location);
            this.m_selectOperationsForm.ShouldUseDefaultLocation = true;
            this.m_useDefaultLocSelectOperationsDlg = false;
          }
          this.m_selectOperationsForm.Show(this.m_targetOperation, this.m_sourceOperation, true);
        }
      }
    }
    catch (Exception ex)
    {
      if (this.m_selectOperationsForm != null)
        this.m_selectOperationsForm = (CUiROMSelectOperationsForm) null;
      flag = false;
    }
    if (this.m_selectOperationsForm != null)
      ((ToolBarButton) this.m_selectOperationsButton).Enabled = false;
    return flag;
  }

  private bool RunSettings()
  {
    bool flag = true;
    try
    {
      if (!this.m_areSettingsLoaded)
        flag = this.LoadSettings();
      if (flag)
        new CUiROMSettingsForm().ShowDialog(this.m_automaticLogSettings);
      this.m_selectOperationsForm = (CUiROMSelectOperationsForm) null;
    }
    catch (Exception ex)
    {
      flag = false;
    }
    return flag;
  }

  public bool RunAutomaticMatch()
  {
    Cursor current = Cursor.Current;
    Cursor.Current = Cursors.WaitCursor;
    bool flag;
    try
    {
      if (this.m_isEmphasizeMode)
        this.ClearAllEmphasizedPairs(false);
      bool matchFound = false;
      flag = this.m_dataManager.ExecuteAutomaticMatch(ref matchFound);
      for (int index = 1; index < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count; ++index)
      {
        Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[index].Node;
        if (node != null)
        {
          if (node.Key is CUiROMTargetInfo key)
          {
            if (key.MatchedObject != null)
            {
              if (this.IsNodeOfTypeSeamOperation(index))
              {
                key.ShouldMerge = true;
              }
              else
              {
                ITxLocatableObject nodeObject = key.NodeObject as ITxLocatableObject;
                ITxLocatableObject matchedObject = key.MatchedObject as ITxLocatableObject;
                if (nodeObject != null && matchedObject != null)
                {
                  key.ShouldMerge = true;
                  key.Distance = this.m_dataManager.CalculateDistanceBetween2Locs(nodeObject, matchedObject);
                }
                else
                {
                  key.MatchedObject = (ITxObject) null;
                  key.ShouldMerge = false;
                  key.Distance = 0.0;
                }
              }
            }
            else
            {
              key.ShouldMerge = false;
              key.Distance = 0.0;
            }
          }
          if (node.Key is CUiROMGridNodeInfo && (node.Key as CUiROMGridNodeInfo).MergeScheme == "")
            this.SetMergeSchemaOfNode(node.Key as CUiROMGridNodeInfo);
        }
      }
      ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
      this.m_targetOperationGrid.UpdateRows(1, ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count - 1, false);
      ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
      ((ScrollableControl) this.m_sourceOperationGrid).BeginUpdate();
      this.m_sourceOperationGrid.UpdateRows(1, ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count - 1, false);
      ((ScrollableControl) this.m_sourceOperationGrid).EndUpdate();
      if (this.m_isEmphasizeMode)
        this.EmphasizeTargetSelection();
    }
    catch (Exception ex)
    {
      flag = false;
    }
    Cursor.Current = current;
    return flag;
  }

  private void SetMergeSchemaOfNode(CUiROMGridNodeInfo nodeInfo)
  {
    bool flag = false;
    if (nodeInfo is CUiROMRoboticTargetOperationInfo && (nodeInfo as CUiROMRoboticTargetOperationInfo).MatchedOperation != null)
      flag = true;
    else if (nodeInfo is CUiROMTargetInfo && (nodeInfo as CUiROMTargetInfo).MatchedObject != null)
      flag = true;
    if (!flag)
      return;
    if (nodeInfo.NodeType == CUiROMDataUtils.NodeType.SeamLocation || nodeInfo.NodeType == CUiROMDataUtils.NodeType.WeldLocation)
      nodeInfo.MergeScheme = CApROMStringTable.Default;
    else if (nodeInfo.NodeType == CUiROMDataUtils.NodeType.ViaLocation || nodeInfo.NodeType == CUiROMDataUtils.NodeType.PickLocation || nodeInfo.NodeType == CUiROMDataUtils.NodeType.PlaceLocation || nodeInfo.NodeType == CUiROMDataUtils.NodeType.GenericLocation || nodeInfo.NodeType == CUiROMDataUtils.NodeType.ObjectFlowLocation)
      nodeInfo.MergeScheme = CApROMStringTable.ViaLocation;
    else
      nodeInfo.MergeScheme = CApROMStringTable.Operation;
  }

  private void SetAlternateSchemaColumn(CUiROMGridNodeInfo nodeInfo)
  {
    bool flag = false;
    if (nodeInfo is CUiROMRoboticTargetOperationInfo && (nodeInfo as CUiROMRoboticTargetOperationInfo).MatchedOperation != null)
      flag = true;
    else if (nodeInfo is CUiROMTargetInfo && (nodeInfo as CUiROMTargetInfo).MatchedObject != null)
      flag = true;
    if (!flag)
      return;
    if (nodeInfo.NodeType == CUiROMDataUtils.NodeType.SeamLocation)
    {
      nodeInfo.MergeScheme = CApROMStringTable.Alternate;
    }
    else
    {
      if (nodeInfo.NodeType != CUiROMDataUtils.NodeType.WeldLocation)
        return;
      nodeInfo.MergeScheme = CApROMStringTable.Alternate;
    }
  }

  private CUiROMDataUtils.MergeSchema GetSchemaFromColumn(CUiROMGridNodeInfo obj)
  {
    return !(obj.MergeScheme == CApROMStringTable.Default) ? (!(obj.MergeScheme == CApROMStringTable.Alternate) ? (!(obj.MergeScheme == CApROMStringTable.ViaLocation) ? CUiROMDataUtils.MergeSchema.Operation : CUiROMDataUtils.MergeSchema.Via) : CUiROMDataUtils.MergeSchema.LocAlternative) : CUiROMDataUtils.MergeSchema.LocDefault;
  }

  private bool RunMatch(bool useDefaultMergeSchemaForLocs)
  {
    bool flag = true;
    try
    {
      CUiROMSourceInfo cuiRomSourceInfo = (CUiROMSourceInfo) null;
      if (this.m_sourceOperationGrid.SelectedTreeRows.Count == 1)
      {
        int selectedTreeRow = this.m_sourceOperationGrid.SelectedTreeRows[0];
        if (selectedTreeRow > 1 && selectedTreeRow < ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count)
        {
          Node node = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[selectedTreeRow].Node;
          if (node != null)
            cuiRomSourceInfo = node.Key as CUiROMSourceInfo;
        }
      }
      if (cuiRomSourceInfo != null)
      {
        if (cuiRomSourceInfo.NodeObject != null)
        {
          List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
          int count = ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count;
          foreach (int index in selectedTreeRows)
          {
            if (index > 1 && index < count)
            {
              Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[index].Node;
              if (node != null && node.Key is CUiROMTargetInfo key && key.BelongToTarget && key.NodeObject != null && this.m_dataManager.AreObjectsCompatible(key.NodeObject, cuiRomSourceInfo.NodeObject) && (useDefaultMergeSchemaForLocs || key.NodeType == CUiROMDataUtils.NodeType.SeamLocation || key.NodeType == CUiROMDataUtils.NodeType.WeldLocation))
              {
                if (this.m_isEmphasizeMode && !this.IsNodeOfTypeSeamOperation(index))
                {
                  if (key.BelongToTarget)
                  {
                    this.UnEmphasizePair(key.NodeObject, key.MatchedObject);
                    this.EmphasizePair(key.NodeObject, cuiRomSourceInfo.NodeObject);
                  }
                  else
                  {
                    this.UnEmphasizePair((ITxObject) null, key.MatchedObject);
                    this.EmphasizePair((ITxObject) null, cuiRomSourceInfo.NodeObject);
                  }
                }
                ITxObject matchedObject1 = key.MatchedObject;
                key.MatchedObject = cuiRomSourceInfo.NodeObject;
                if (matchedObject1 != null)
                  this.m_dataManager.RefreshMatchedIndication(matchedObject1);
                cuiRomSourceInfo.Matched = true;
                if (!this.IsNodeOfTypeSeamOperation(index))
                {
                  ITxLocatableObject nodeObject = key.NodeObject as ITxLocatableObject;
                  ITxLocatableObject matchedObject2 = key.MatchedObject as ITxLocatableObject;
                  if (nodeObject != null && matchedObject2 != null)
                  {
                    key.Distance = this.m_dataManager.CalculateDistanceBetween2Locs(nodeObject, matchedObject2);
                  }
                  else
                  {
                    key.MatchedObject = (ITxObject) null;
                    key.ShouldMerge = false;
                    key.Distance = 0.0;
                    cuiRomSourceInfo.Matched = false;
                  }
                }
                key.ShouldMerge = true;
                if (node.Key is CUiROMGridNodeInfo)
                {
                  if (useDefaultMergeSchemaForLocs)
                    this.SetMergeSchemaOfNode(node.Key as CUiROMGridNodeInfo);
                  else
                    this.SetAlternateSchemaColumn(node.Key as CUiROMGridNodeInfo);
                }
              }
            }
          }
          ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
          this.m_targetOperationGrid.UpdateRows(2, count - 2, false);
          ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
          ((ScrollableControl) this.m_sourceOperationGrid).BeginUpdate();
          this.m_sourceOperationGrid.UpdateRows(2, ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count - 2, true);
          ((ScrollableControl) this.m_sourceOperationGrid).EndUpdate();
          TxApplication.RefreshDisplay();
        }
      }
    }
    catch (Exception ex)
    {
      flag = false;
    }
    return flag;
  }

  private bool RunAddLocationsBefore()
  {
    return !(this.m_targetOperation is ITxContinuousOperation) ? (!(this.m_targetOperation is TxRoboticSeamOperation) ? this.AddLocationsWithinWeldOp(false) : this.AddLocationsWithinSeamOp(false)) : this.AddLocationsWithinContOp(false);
  }

  private bool RunReplaceEmptyTarget()
  {
    bool flag = this.RunAddLocationsAfter();
    if (flag)
    {
      ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
      this.m_targetOperationGrid.RemoveRows(new List<int>()
      {
        this.m_targetOperationGrid.SelectedTreeRows[0]
      }, false);
      this.m_targetOperationGrid.UpdateRows(1, ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count - 1, true);
      ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
    }
    return flag;
  }

  private bool RunAddLocationsAfter()
  {
    return !(this.m_targetOperation is ITxContinuousOperation) ? (!(this.m_targetOperation is TxRoboticSeamOperation) ? this.AddLocationsWithinWeldOp(true) : this.AddLocationsWithinSeamOp(true)) : this.AddLocationsWithinContOp(true);
  }

  private bool AddLocationsWithinContOp(bool afterFlag)
  {
    bool flag = true;
    if (!this.IsSelectionValidForInsertToContOp())
      return false;
    try
    {
      List<int> selectedTreeRows1 = this.m_targetOperationGrid.SelectedTreeRows;
      if (selectedTreeRows1.Count != 1)
        return flag;
      int num1 = selectedTreeRows1[0];
      if (afterFlag)
      {
        if (this.IsNodeOfTypeSeamOperation(num1))
          num1 += this.CountNodesOfSeamOperation(num1);
        else
          ++num1;
      }
      List<int> selectedTreeRows2 = this.m_sourceOperationGrid.SelectedTreeRows;
      List<CUiROMSourceInfo> sourceLocationsList = new List<CUiROMSourceInfo>();
      selectedTreeRows2.Sort();
      foreach (int num2 in selectedTreeRows2)
      {
        if (num2 > 1 && num2 < ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count)
        {
          Node node = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[num2].Node;
          if (node != null && node.Key is CUiROMSourceInfo key)
            sourceLocationsList.Add(key);
        }
      }
      ArrayList targetOperation = this.m_dataManager.InsertSourceLocationsToTargetOperation(num1 - 2, sourceLocationsList);
      if (targetOperation != null && targetOperation.Count > 0)
      {
        ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
        this.m_targetOperationGrid.InsertRows(num1, targetOperation, true);
        ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
      }
      foreach (CUiROMGridNodeInfo cuiRomGridNodeInfo in sourceLocationsList)
        this.m_dataManager.RefreshMatchedIndication(cuiRomGridNodeInfo.NodeObject);
      ((ScrollableControl) this.m_sourceOperationGrid).BeginUpdate();
      this.m_sourceOperationGrid.UpdateRows(2, ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count - 2, true);
      ((ScrollableControl) this.m_sourceOperationGrid).EndUpdate();
    }
    catch (Exception ex)
    {
      flag = false;
    }
    return flag;
  }

  private bool AddLocationsWithinSeamOp(bool afterFlag)
  {
    bool flag = true;
    try
    {
      List<int> selectedTreeRows1 = this.m_targetOperationGrid.SelectedTreeRows;
      if (selectedTreeRows1.Count != 1)
        return flag;
      int rowIndex = selectedTreeRows1[0];
      if (afterFlag)
        ++rowIndex;
      List<int> selectedTreeRows2 = this.m_sourceOperationGrid.SelectedTreeRows;
      List<CUiROMSourceInfo> sourceLocationsList = new List<CUiROMSourceInfo>();
      selectedTreeRows2.Sort();
      foreach (int num in selectedTreeRows2)
      {
        if (num > 1 && num < ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count)
        {
          Node node = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[num].Node;
          if (node != null && node.Key is CUiROMSourceInfo key)
            sourceLocationsList.Add(key);
        }
      }
      ArrayList targetOperation = this.m_dataManager.InsertSourceLocationsToTargetOperation(rowIndex - 2, sourceLocationsList);
      if (targetOperation != null && targetOperation.Count > 0)
      {
        ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
        this.m_targetOperationGrid.InsertRows(rowIndex, targetOperation, true);
        ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
      }
      foreach (CUiROMGridNodeInfo cuiRomGridNodeInfo in sourceLocationsList)
        this.m_dataManager.RefreshMatchedIndication(cuiRomGridNodeInfo.NodeObject);
      ((ScrollableControl) this.m_sourceOperationGrid).BeginUpdate();
      this.m_sourceOperationGrid.UpdateRows(2, ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count - 2, true);
      ((ScrollableControl) this.m_sourceOperationGrid).EndUpdate();
    }
    catch (Exception ex)
    {
      flag = false;
    }
    return flag;
  }

  private bool AddLocationsWithinWeldOp(bool afterFlag)
  {
    bool flag1 = true;
    try
    {
      List<int> selectedTreeRows1 = this.m_targetOperationGrid.SelectedTreeRows;
      List<int> selectedTreeRows2 = this.m_sourceOperationGrid.SelectedTreeRows;
      List<CUiROMSourceInfo> sourceLocationsList = new List<CUiROMSourceInfo>();
      bool flag2 = true;
      foreach (int num in selectedTreeRows2)
      {
        if (num > 1 && num < ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count)
        {
          Node node = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[num].Node;
          if (node != null && node.Key is CUiROMSourceInfo key && !key.CanBeAdded)
          {
            flag2 = false;
            break;
          }
        }
      }
      if (!flag2)
      {
        this.NotifyAboutUnableToAddLocations();
        flag1 = false;
      }
      else if (selectedTreeRows1.Count == 1)
      {
        int rowIndex = selectedTreeRows1[0];
        if (afterFlag)
          ++rowIndex;
        selectedTreeRows2.Sort();
        foreach (int num in selectedTreeRows2)
        {
          if (num > 1 && num < ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count)
          {
            Node node = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[num].Node;
            if (node != null && node.Key is CUiROMSourceInfo key)
              sourceLocationsList.Add(key);
          }
        }
        ArrayList targetOperation = this.m_dataManager.InsertSourceLocationsToTargetOperation(rowIndex - 2, sourceLocationsList);
        if (targetOperation != null && targetOperation.Count > 0)
        {
          ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
          this.m_targetOperationGrid.InsertRows(rowIndex, targetOperation, true);
          ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
        }
        foreach (CUiROMGridNodeInfo cuiRomGridNodeInfo in sourceLocationsList)
          this.m_dataManager.RefreshMatchedIndication(cuiRomGridNodeInfo.NodeObject);
        ((ScrollableControl) this.m_sourceOperationGrid).BeginUpdate();
        this.m_sourceOperationGrid.UpdateRows(2, ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count - 2, true);
        ((ScrollableControl) this.m_sourceOperationGrid).EndUpdate();
      }
    }
    catch (Exception ex)
    {
      flag1 = false;
    }
    return flag1;
  }

  private bool RunEmphasizePair()
  {
    bool flag = true;
    try
    {
      if (((ToolBarButton) this.m_emphasizePairButton).Pushed)
      {
        this.m_isEmphasizeMode = true;
        this.EmphasizeTargetSelection();
      }
      else
      {
        this.m_isEmphasizeMode = false;
        this.ClearAllEmphasizedPairs(true);
      }
    }
    catch (Exception ex)
    {
    }
    return flag;
  }

  private bool RunUnMatch()
  {
    bool flag = true;
    try
    {
      int num1 = 3;
      if (((C1FlexGridBase) this.m_targetOperationGrid).Cols.Contains("Merge"))
        num1 = ((RowCol) ((C1FlexGridBase) this.m_targetOperationGrid).Cols["Merge"]).Index;
      List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
      int count = ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count;
      foreach (int num2 in selectedTreeRows)
      {
        if (num2 > 0 && num2 < count)
        {
          Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[num2].Node;
          if (node != null)
          {
            if (node.Key is CUiROMGridNodeInfo)
              (node.Key as CUiROMGridNodeInfo).MergeScheme = "";
            if (node.Key is CUiROMTargetInfo key && key.BelongToTarget && key.MatchedObject != null)
            {
              if (this.m_isEmphasizeMode)
              {
                if (key.BelongToTarget)
                  this.UnEmphasizePair(key.NodeObject, key.MatchedObject);
                else
                  this.UnEmphasizePair((ITxObject) null, key.MatchedObject);
              }
              ITxObject matchedObject = key.MatchedObject;
              key.MatchedObject = (ITxObject) null;
              key.ShouldMerge = false;
              key.Distance = 0.0;
              ((C1FlexGridBase) this.m_targetOperationGrid).SetCellCheck(num2, num1, (CheckEnum) 0);
              this.m_dataManager.RefreshMatchedIndication(matchedObject);
            }
          }
        }
      }
      ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
      this.m_targetOperationGrid.UpdateRows(2, count - 2, false);
      ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
      ((ScrollableControl) this.m_sourceOperationGrid).BeginUpdate();
      this.m_sourceOperationGrid.UpdateRows(2, ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count - 2, true);
      ((ScrollableControl) this.m_sourceOperationGrid).EndUpdate();
      TxApplication.RefreshDisplay();
    }
    catch (Exception ex)
    {
      flag = false;
    }
    return flag;
  }

  private bool RunDeleteUnmatched()
  {
    List<int> selectedRows = new List<int>();
    try
    {
      for (int index = 1; index < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count; ++index)
      {
        Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[index].Node;
        if (node != null)
        {
          CUiROMTargetInfo key1 = node.Key as CUiROMTargetInfo;
          CUiROMRoboticTargetOperationInfo key2 = node.Key as CUiROMRoboticTargetOperationInfo;
          if (key1 != null && key1.BelongToTarget && key1.MatchedObject == null && (!this.IsNodeOfTypeSeamOperation(index) || this.NoSeamLocsOfSeamOpAreMatched(index)))
            selectedRows.Add(index);
        }
      }
      return this.RemoveFromRows(selectedRows, this.GetResourceManager().GetString("WARNING_UNMATACH_ACTION_NAME"));
    }
    catch (Exception ex)
    {
      return false;
    }
  }

  private bool RunMoveLocationsUp()
  {
    bool flag = true;
    if (this.m_targetOperation is ITxContinuousOperation)
    {
      flag = this.RunMoveUpInContOp();
    }
    else
    {
      try
      {
        List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
        for (int index = 0; index < selectedTreeRows.Count; ++index)
        {
          if (selectedTreeRows[index] > 1 && selectedTreeRows[index] < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count)
          {
            Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[selectedTreeRows[index]].Node;
            if (node != null && node.Key is CUiROMTargetInfo key && key.BelongToTarget)
            {
              this.m_isTargetLocationChanged = true;
              break;
            }
          }
        }
        ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
        this.m_targetOperationGrid.MoveRows(selectedTreeRows, -1, true);
        ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
        this.RefreshTargetLocationsPositions();
      }
      catch (Exception ex)
      {
        flag = false;
      }
    }
    return flag;
  }

  private bool RunMoveUpInContOp()
  {
    bool flag1 = true;
    try
    {
      List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
      List<int> intList = new List<int>((IEnumerable<int>) this.m_targetOperationGrid.SelectedTreeRows);
      for (int index1 = 0; index1 < selectedTreeRows.Count; ++index1)
      {
        if (this.IsNodeOfTypeSeamOperation(selectedTreeRows[index1]))
        {
          bool flag2 = false;
          for (int index2 = selectedTreeRows[index1] + 1; !flag2 && index2 < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count; ++index2)
          {
            if (this.IsNodeOfTypeSeamLocation(index2))
            {
              if (!intList.Contains(index2))
                intList.Add(index2);
            }
            else
              flag2 = true;
          }
        }
      }
      intList.Sort();
      List<int> rows = new List<int>();
      rows.Add(intList[0]);
      for (int index = 1; index < intList.Count; ++index)
      {
        if (intList[index] != intList[index - 1] + 1)
        {
          int num = this.CountNodesOfPreviousItem(rows[0]);
          if (num > 0)
          {
            ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
            this.m_targetOperationGrid.MoveRows(rows, -1 * num, true);
            ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
            this.m_isTargetLocationChanged = true;
            rows.Clear();
          }
        }
        rows.Add(intList[index]);
      }
      if (rows.Count > 0)
      {
        int num = this.CountNodesOfPreviousItem(rows[0]);
        if (num > 0)
        {
          ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
          this.m_targetOperationGrid.MoveRows(rows, -1 * num, true);
          ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
          this.m_isTargetLocationChanged = true;
        }
      }
      this.RefreshTargetLocationsPositions();
    }
    catch (Exception ex)
    {
      flag1 = false;
    }
    return flag1;
  }

  private bool RunMoveLocationsDown()
  {
    bool flag = true;
    if (this.m_targetOperation is ITxContinuousOperation)
    {
      flag = this.RunMoveDownInContOp();
    }
    else
    {
      try
      {
        List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
        for (int index = 0; index < selectedTreeRows.Count; ++index)
        {
          if (selectedTreeRows[index] > 1 && selectedTreeRows[index] < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count)
          {
            Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[selectedTreeRows[index]].Node;
            if (node != null && node.Key is CUiROMTargetInfo key && key.BelongToTarget)
            {
              this.m_isTargetLocationChanged = true;
              break;
            }
          }
        }
        ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
        this.m_targetOperationGrid.MoveRows(selectedTreeRows, 1, true);
        ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
        this.RefreshTargetLocationsPositions();
      }
      catch (Exception ex)
      {
        flag = false;
      }
    }
    return flag;
  }

  private bool RunMoveDownInContOp()
  {
    bool flag1 = true;
    try
    {
      List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
      List<int> intList = new List<int>((IEnumerable<int>) this.m_targetOperationGrid.SelectedTreeRows);
      for (int index1 = 0; index1 < selectedTreeRows.Count; ++index1)
      {
        if (this.IsNodeOfTypeSeamOperation(selectedTreeRows[index1]))
        {
          bool flag2 = false;
          for (int index2 = selectedTreeRows[index1] + 1; !flag2 && index2 < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count; ++index2)
          {
            if (this.IsNodeOfTypeSeamLocation(index2))
            {
              if (!intList.Contains(index2))
                intList.Add(index2);
            }
            else
              flag2 = true;
          }
        }
      }
      intList.Sort();
      List<int> rows = new List<int>();
      rows.Add(intList[0]);
      for (int index = 1; index < intList.Count; ++index)
      {
        if (intList[index] != intList[index - 1] + 1)
        {
          int offset = this.CountNodesOfNextItem(rows[rows.Count - 1]);
          if (offset > 0)
          {
            ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
            this.m_targetOperationGrid.MoveRows(rows, offset, true);
            ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
            this.m_isTargetLocationChanged = true;
            rows.Clear();
          }
        }
        rows.Add(intList[index]);
      }
      if (rows.Count > 0)
      {
        int offset = this.CountNodesOfNextItem(rows[rows.Count - 1]);
        if (offset > 0)
        {
          ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
          this.m_targetOperationGrid.MoveRows(rows, offset, true);
          ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
          this.m_isTargetLocationChanged = true;
        }
      }
      this.RefreshTargetLocationsPositions();
    }
    catch (Exception ex)
    {
      flag1 = false;
    }
    return flag1;
  }

  private bool RemoveAllEmptyLines(CUiROMRoboticOperationGridWrapper OperationGrid)
  {
    bool flag = true;
    List<int> rows = new List<int>();
    for (int index = 1; index < ((RowColCollection) ((C1FlexGridBase) OperationGrid).Rows).Count; ++index)
    {
      Node node = ((C1FlexGridBase) OperationGrid).Rows[index].Node;
      if (node != null && node.Key is CUiROMGridNodeInfo key && key.NodeType == CUiROMDataUtils.NodeType.NotSet)
        rows.Add(index);
    }
    if (rows.Count > 0)
    {
      List<int> selectedTreeRows = OperationGrid.SelectedTreeRows;
      List<CUiROMGridNodeInfo> cuiRomGridNodeInfoList = new List<CUiROMGridNodeInfo>();
      foreach (int num in selectedTreeRows)
      {
        Node node = ((C1FlexGridBase) OperationGrid).Rows[num].Node;
        if (node.Key != null && node.Key is CUiROMGridNodeInfo)
          cuiRomGridNodeInfoList.Add(node.Key as CUiROMGridNodeInfo);
      }
      OperationGrid.RemoveRows(rows, false);
      foreach (CUiROMGridNodeInfo cuiRomGridNodeInfo in cuiRomGridNodeInfoList)
      {
        if (cuiRomGridNodeInfo != null)
          cuiRomGridNodeInfo.State = CUiROMDataUtils.CellState.Selected;
      }
    }
    return flag;
  }

  private bool RunReorder()
  {
    bool flag1 = true;
    ((ScrollableControl) this.m_sourceOperationGrid).BeginUpdate();
    ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
    flag1 = this.RemoveAllEmptyLines(this.m_sourceOperationGrid);
    bool flag2 = this.RemoveAllEmptyLines(this.m_targetOperationGrid);
    int count1 = ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count;
    int count2 = ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count;
    int num = 2;
    for (int index1 = 2; index1 < count1; ++index1)
    {
      Node node1 = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[index1].Node;
      if (node1.Key is CUiROMSourceInfo)
      {
        ITxObject nodeObject = (node1.Key as CUiROMSourceInfo).NodeObject;
        for (int index2 = num; index2 < count2; ++index2)
        {
          Node node2 = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[index2].Node;
          if (node2.Key is CUiROMTargetInfo && (node2.Key as CUiROMTargetInfo).MatchedObject == nodeObject)
          {
            for (int index3 = index2; index3 > num; --index3)
              node2.Move((NodeMoveEnum) 2);
            index2 = num;
            ++num;
          }
        }
      }
    }
    if (flag2)
      flag2 = this.RunReorderWithSpaces();
    this.m_sourceOperationGrid.UpdateRows(1, ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count - 1, true);
    this.m_targetOperationGrid.UpdateRows(1, ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count - 1, true);
    ((ScrollableControl) this.m_sourceOperationGrid).EndUpdate();
    ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
    return flag2;
  }

  private bool RunReorderWithSpaces()
  {
    bool flag = false;
    int count1 = ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count;
    int count2 = ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count;
    ArrayList arrayList1 = new ArrayList();
    ArrayList arrayList2 = new ArrayList();
    int num1 = 2;
    int num2 = 2;
label_7:
    while (num1 < count2 && num2 < count1)
    {
      CUiROMTargetInfo key1 = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[num1].Node.Key as CUiROMTargetInfo;
      CUiROMSourceInfo key2 = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[num2].Node.Key as CUiROMSourceInfo;
      if (key1 != null && key2 != null)
      {
        if (key1.MatchedObject != key2.NodeObject)
        {
          int num3 = arrayList2.Count + num1;
          arrayList2.Add((object) num3);
          ++num2;
        }
        else
        {
          ++num2;
          ++num1;
          while (true)
          {
            if (num1 < count2 && ((C1FlexGridBase) this.m_targetOperationGrid).Rows[num1].Node.Key is CUiROMTargetInfo key3 && key3.MatchedObject == key1.MatchedObject)
            {
              int num4 = arrayList1.Count + num2;
              arrayList1.Add((object) num4);
              ++num1;
            }
            else
              goto label_7;
          }
        }
      }
    }
    ArrayList nodeInfoList = new ArrayList();
    foreach (int rowIndex in arrayList1)
    {
      CUiROMSourceInfo emptySourceLine = this.CreateEmptySourceLine();
      nodeInfoList.Add((object) emptySourceLine);
      this.m_sourceOperationGrid.InsertRows(rowIndex, nodeInfoList, true);
      nodeInfoList.Clear();
    }
    foreach (int rowIndex in arrayList2)
    {
      CUiROMTargetInfo emptyTargetLine = this.CreateEmptyTargetLine();
      nodeInfoList.Add((object) emptyTargetLine);
      this.m_targetOperationGrid.InsertRows(rowIndex, nodeInfoList, true);
      nodeInfoList.Clear();
    }
    return flag;
  }

  private CUiROMTargetInfo CreateEmptyTargetLine()
  {
    CUiROMTargetInfo emptyTargetLine = new CUiROMTargetInfo();
    emptyTargetLine.NodeObject = (ITxObject) null;
    emptyTargetLine.NiceName = $"<{CApROMStringTable.Empty}>";
    emptyTargetLine.NodeType = CUiROMDataUtils.NodeType.NotSet;
    emptyTargetLine.Level = 1;
    emptyTargetLine.BelongToTarget = true;
    emptyTargetLine.Distance = 0.0;
    emptyTargetLine.MatchedObject = (ITxObject) null;
    emptyTargetLine.ShouldMerge = false;
    emptyTargetLine.SetCustomStyle(CUiROMDataUtils.CellStyleCategory.Normal, "targetLocationNormalStyle");
    emptyTargetLine.SetCustomStyle(CUiROMDataUtils.CellStyleCategory.Select, "targetLocationSelectStyle");
    emptyTargetLine.State = CUiROMDataUtils.CellState.Normal;
    return emptyTargetLine;
  }

  private CUiROMSourceInfo CreateEmptySourceLine()
  {
    CUiROMSourceInfo emptySourceLine = new CUiROMSourceInfo();
    emptySourceLine.NodeObject = (ITxObject) null;
    emptySourceLine.NiceName = $"<{CApROMStringTable.Empty}>";
    emptySourceLine.NodeType = CUiROMDataUtils.NodeType.NotSet;
    emptySourceLine.Level = 1;
    emptySourceLine.SetCustomStyle(CUiROMDataUtils.CellStyleCategory.Normal, "sourceLocationNormalStyle");
    emptySourceLine.SetCustomStyle(CUiROMDataUtils.CellStyleCategory.Select, "sourceLocationSelectStyle");
    emptySourceLine.State = CUiROMDataUtils.CellState.Normal;
    return emptySourceLine;
  }

  private bool RunReverse()
  {
    bool flag = true;
    Cursor cursor = ((Control) this).Cursor;
    Cursor.Current = Cursors.WaitCursor;
    this.m_isTargetLocationChanged = true;
    ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
    List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
    if (selectedTreeRows.Count == 1)
    {
      this.RunReverse(((C1FlexGridBase) this.m_targetOperationGrid).Rows[selectedTreeRows[0]].Node, false);
    }
    else
    {
      Node node1 = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[selectedTreeRows[0]].Node;
      Node node2 = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[selectedTreeRows[1]].Node;
      int rowIndex = selectedTreeRows[0];
      int num1 = selectedTreeRows[1];
      int num2 = node1.Index;
      int num3 = node2.Index;
      if (num2 > num3)
      {
        int num4 = num2;
        num2 = num3;
        num3 = num4;
        int num5 = rowIndex;
        rowIndex = num1;
        num1 = num5;
      }
      List<Node> childNodes = this.GetChildNodes(node1.Parent);
      List<Node> nodes = new List<Node>();
      for (int index = num2; index <= num3; ++index)
      {
        nodes.Add(childNodes[index]);
        (childNodes[index].Key as CUiROMGridNodeInfo).State = CUiROMDataUtils.CellState.Selected;
      }
      this.ReverseNodes(nodes, true);
      this.m_targetOperationGrid.UpdateRows(rowIndex, num1 - rowIndex + 1, true);
    }
    ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
    this.RefreshTargetLocationsPositions();
    Cursor.Current = cursor;
    return flag;
  }

  private bool RunReverse(Node currentNode, bool shoulBeSelected)
  {
    bool flag = true;
    if (currentNode != null && currentNode.Children > 0)
      this.ReverseNodes(this.GetChildNodes(currentNode), shoulBeSelected);
    return flag;
  }

  private void ReverseNodes(List<Node> nodes, bool shoulBeSelected)
  {
    int index1 = 0;
    for (int index2 = nodes.Count - 1; index1 < nodes.Count / 2 && index2 >= nodes.Count / 2; --index2)
    {
      int num = index2 - index1;
      if (num == 1 && index2 == nodes.Count / 2)
      {
        nodes[index1].Move((NodeMoveEnum) 3);
      }
      else
      {
        for (int index3 = 0; index3 < num; ++index3)
          nodes[index1].Move((NodeMoveEnum) 3);
        for (int index4 = 1; index4 < num; ++index4)
          nodes[index2].Move((NodeMoveEnum) 2);
      }
      ++index1;
    }
    foreach (Node node in nodes)
    {
      if (shoulBeSelected)
        (node.Key as CUiROMGridNodeInfo).State = CUiROMDataUtils.CellState.Selected;
      this.RunReverse(node, shoulBeSelected);
    }
    if (!shoulBeSelected)
      return;
    int index5 = ((RowCol) (nodes[0].Key as CUiROMGridNodeInfo).GridRow).Index;
    int index6 = ((RowCol) (nodes[nodes.Count - 1].Key as CUiROMGridNodeInfo).GridRow).Index;
    this.m_targetOperationGrid.UpdateRows(index6, index5 - index6 + 1, true);
  }

  internal List<Node> GetChildNodes(Node parentNode)
  {
    List<Node> childNodes = new List<Node>();
    if (parentNode.Children > 0)
    {
      Node node1 = parentNode.GetNode((NodeTypeEnum) 2);
      if (node1 != null)
      {
        childNodes.Add(node1);
        for (Node node2 = node1.GetNode((NodeTypeEnum) 6); node2 != null; node2 = node2.GetNode((NodeTypeEnum) 6))
          childNodes.Add(node2);
      }
    }
    return childNodes;
  }

  private bool RunRemoveFromTarget()
  {
    bool flag = true;
    try
    {
      List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
      List<CUiROMTargetInfo> cuiRomTargetInfoList = new List<CUiROMTargetInfo>();
      TxObjectList txObjectList = new TxObjectList();
      this.AddSeamLocsOfSeamOpsToList(selectedTreeRows);
      this.RemoveFromRows(selectedTreeRows, this.GetResourceManager().GetString("WARNING_DELETE_ACTION_NAME"));
    }
    catch (Exception ex)
    {
      flag = false;
    }
    return flag;
  }

  private bool RemoveFromRows(List<int> selectedRows, string actionNameForMessage)
  {
    bool flag1 = true;
    int num1 = 0;
    int num2 = 0;
    string str1 = "";
    List<CUiROMTargetInfo> childList = new List<CUiROMTargetInfo>();
    foreach (int selectedRow in selectedRows)
    {
      Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[selectedRow].Node;
      if (node != null && node.Key is CUiROMTargetInfo key)
      {
        childList.Add(key);
        num2 += key.NodeObject == null ? 0 : 1;
        if ((key.NodeType == CUiROMDataUtils.NodeType.WeldLocation || key.NodeType == CUiROMDataUtils.NodeType.UnprojectedWeldLocation) && !key.NodeObject.CanBeDeleted)
        {
          if (num1 < 10)
          {
            TxWeldPoint weldPoint = (key.NodeObject as TxWeldLocationOperation).WeldPoint;
            string str2 = "";
            if (TxWeldPoint.op_Inequality(weldPoint, (ITxObject) null))
              str2 = ((TxMfgFeature) weldPoint).Name;
            string format = this.GetResourceManager().GetString("WARNING_WELD_LOCATION_LIST_LINE");
            str1 += string.Format(format, (object) key.NodeObject.Name, (object) str2);
          }
          if (num1 == 10)
            str1 += this.GetResourceManager().GetString("WARNING_DELETE_LONG_LIST");
          ++num1;
        }
      }
    }
    bool flag2 = true;
    if (num2 > 0)
    {
      string str3 = this.GetResourceManager().GetString("WARNING_CAPTION");
      string str4;
      if (this.m_weldLocationContainer == null || num1 == 0)
      {
        str4 = this.GetResourceManager().GetString("WARNING_DELETED_WELD_POINT");
      }
      else
      {
        string format = this.GetResourceManager().GetString("WARNING_MOVED_TO_FORMAT");
        string name = ((ITxObject) this.m_weldLocationContainer).Name;
        if (string.IsNullOrEmpty(name) && this.m_weldLocationContainer == TxApplication.ActiveDocument.OperationRoot)
          name = this.GetResourceManager().GetString("LOG_MOVE_OPERATION_ROOT");
        str4 = string.Format(format, (object) name);
      }
      string str5 = string.Format(this.GetResourceManager().GetString("WARNING_DELETE_UNMATCHED"), (object) actionNameForMessage);
      if (num1 > 0)
      {
        string format = this.GetResourceManager().GetString("WARNING_REMOVING_LAST_WELD_LOCATION");
        str5 += string.Format(format, (object) num1, (object) str4, (object) str1);
        if (TxTcUtilities.IsTcAnyPlatform && this.m_weldLocationContainer != null)
          str5 += this.GetResourceManager().GetString("WARNING_TC_PROJECTION_LOST");
      }
      flag2 = TxMessageBox.Show(str5 + this.GetResourceManager().GetString("WARNING_DELETE_PROCEED"), str3, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes;
    }
    if (!flag2)
    {
      flag1 = false;
    }
    else
    {
      foreach (CUiROMTargetInfo cuiRomTargetInfo in childList)
      {
        if (this.m_isEmphasizeMode)
        {
          ITxObject targetLocation = (ITxObject) null;
          if (cuiRomTargetInfo.BelongToTarget)
            targetLocation = cuiRomTargetInfo.NodeObject;
          this.UnEmphasizePair(targetLocation, cuiRomTargetInfo.MatchedObject);
          this.m_dataManager.RefreshMatchedIndication(cuiRomTargetInfo.MatchedObject);
        }
        if (cuiRomTargetInfo.BelongToTarget)
          this.m_isTargetLocationChanged = true;
      }
      this.m_dataManager.RemoveTargetChildren(childList);
      ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
      this.m_targetOperationGrid.RemoveRows(selectedRows, true);
      ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
      this.m_isTargetLocationChanged = true;
      ((ScrollableControl) this.m_sourceOperationGrid).BeginUpdate();
      this.m_sourceOperationGrid.UpdateRows(2, ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count - 2, true);
      ((ScrollableControl) this.m_sourceOperationGrid).EndUpdate();
      TxApplication.RefreshDisplay();
    }
    return flag1;
  }

  private bool RunSelectAll()
  {
    bool flag = true;
    try
    {
      for (int row = 1; row < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count; ++row)
      {
        Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[row].Node;
        if (node != null)
        {
          CUiROMTargetInfo key1 = node.Key as CUiROMTargetInfo;
          CUiROMRoboticTargetOperationInfo key2 = node.Key as CUiROMRoboticTargetOperationInfo;
          if (key1 != null && key1.BelongToTarget && key1.MatchedObject != null)
          {
            key1.ShouldMerge = true;
            this.m_targetOperationGrid.SetMergeColumn(row, (CheckEnum) 1);
          }
          else if (key2 != null)
          {
            key2.ShouldMerge = true;
            this.m_targetOperationGrid.SetMergeColumn(row, (CheckEnum) 1);
          }
        }
      }
      ((Control) this.m_executeButton).Enabled = this.ExecuteButtonEnabler();
      ((Control) this.m_previewButton).Enabled = this.IsAnyMergeMarked();
    }
    catch (Exception ex)
    {
      flag = false;
    }
    return flag;
  }

  private bool RunUnselectAll()
  {
    bool flag = true;
    try
    {
      for (int row = 1; row < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count; ++row)
      {
        Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[row].Node;
        if (node != null)
        {
          CUiROMTargetInfo key1 = node.Key as CUiROMTargetInfo;
          CUiROMRoboticTargetOperationInfo key2 = node.Key as CUiROMRoboticTargetOperationInfo;
          if (key1 != null && key1.BelongToTarget)
          {
            key1.ShouldMerge = false;
            if (key1.MatchedObject != null)
              this.m_targetOperationGrid.SetMergeColumn(row, (CheckEnum) 2);
            else
              this.m_targetOperationGrid.SetMergeColumn(row, (CheckEnum) 0);
          }
          else if (key2 != null)
          {
            key2.ShouldMerge = false;
            this.m_targetOperationGrid.SetMergeColumn(row, (CheckEnum) 2);
          }
        }
      }
      ((Control) this.m_executeButton).Enabled = this.ExecuteButtonEnabler();
      ((Control) this.m_previewButton).Enabled = this.IsAnyMergeMarked();
    }
    catch (Exception ex)
    {
      flag = false;
    }
    return flag;
  }

  private void m_mainFormToolbar_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
  {
    try
    {
      bool flag = false;
      switch (((ToolBar) this.m_mainFormToolbar).Buttons.IndexOf(e.Button))
      {
        case 0:
          flag = this.RunSelectOperations();
          break;
        case 1:
          flag = this.RunSettings();
          break;
        case 3:
          flag = this.RunAutomaticMatch();
          break;
        case 4:
          flag = this.RunMatch(true);
          break;
        case 5:
          flag = this.RunMatch(false);
          break;
        case 6:
          flag = this.RunUnMatch();
          break;
        case 7:
          flag = this.RunDeleteUnmatched();
          break;
        case 9:
          flag = this.RunAddLocationsBefore();
          break;
        case 10:
          flag = this.RunAddLocationsAfter();
          break;
        case 11:
          flag = this.RunReplaceEmptyTarget();
          break;
        case 12:
          flag = this.RunEmphasizePair();
          break;
        case 14:
          flag = this.RunMoveLocationsUp();
          break;
        case 15:
          flag = this.RunMoveLocationsDown();
          break;
        case 16 /*0x10*/:
          flag = this.RunReverse();
          break;
        case 17:
          flag = this.RunReorder();
          break;
        case 18:
          flag = this.RunRemoveFromTarget();
          break;
        case 20:
          flag = this.RunSelectAll();
          break;
        case 21:
          flag = this.RunUnselectAll();
          break;
      }
      this.UpdateAllButtonEnablers();
    }
    catch (Exception ex)
    {
      this.UpdateAllButtonEnablers();
    }
  }

  private void m_executeButton_Click(object sender, EventArgs e) => this.RunMerge();

  private void m_resetButton_Click(object sender, EventArgs e) => this.RunReset();

  private void m_closeButton_Click(object sender, EventArgs e) => ((Form) this).Close();

  public void RegisterSelectionEvents()
  {
    try
    {
      TxSelection activeSelection = TxApplication.ActiveSelection;
      activeSelection.ItemsAdded += new TxSelection_ItemsAddedEventHandler(this.OnSelectionAdded);
      activeSelection.ItemsRemoved += new TxSelection_ItemsRemovedEventHandler(this.OnSelectionRemoved);
      activeSelection.ItemsSet += new TxSelection_ItemsSetEventHandler(this.OnSelectionSet);
      activeSelection.Cleared += new TxSelection_ClearedEventHandler(this.OnSelectionCleared);
    }
    catch (Exception ex)
    {
    }
  }

  public void UnRegisterSelectionEvents()
  {
    try
    {
      TxSelection activeSelection = TxApplication.ActiveSelection;
      activeSelection.ItemsAdded -= new TxSelection_ItemsAddedEventHandler(this.OnSelectionAdded);
      activeSelection.ItemsRemoved -= new TxSelection_ItemsRemovedEventHandler(this.OnSelectionRemoved);
      activeSelection.ItemsSet -= new TxSelection_ItemsSetEventHandler(this.OnSelectionSet);
      activeSelection.Cleared -= new TxSelection_ClearedEventHandler(this.OnSelectionCleared);
    }
    catch (Exception ex)
    {
    }
  }

  private void OnSelectionAdded(object sender, TxSelection_ItemsAddedEventArgs e)
  {
    if (!this.m_isInternalSelection)
      this.DistributeExternalToGridSelection();
    else
      this.m_isInternalSelection = false;
  }

  private void OnSelectionRemoved(object sender, TxSelection_ItemsRemovedEventArgs e)
  {
    if (!this.m_isInternalSelection)
      this.DistributeExternalToGridSelection();
    else
      this.m_isInternalSelection = false;
  }

  private void OnSelectionSet(object sender, TxSelection_ItemsSetEventArgs e)
  {
    if (!this.m_isInternalSelection)
      this.DistributeExternalToGridSelection();
    else
      this.m_isInternalSelection = false;
  }

  private void OnSelectionCleared(object sender, TxSelection_ClearedEventArgs e)
  {
    if (!this.m_isInternalSelection)
      this.DistributeExternalToGridSelection();
    else
      this.m_isInternalSelection = false;
  }

  private void DistributeExternalToGridSelection()
  {
    TxObjectList items = TxApplication.ActiveSelection.GetItems();
    this.m_targetOperationGrid.SetExternalTreeSelection(items);
    this.m_sourceOperationGrid.SetExternalTreeSelection(items);
    if (this.m_isEmphasizeMode)
      this.EmphasizeTargetSelection();
    this.UpdateOnSelectionButtonEnablers();
  }

  private void m_sourceOperationGrid_TreeSelectionChanged(
    object sender,
    TreeSelectionChangedEventArgs e)
  {
    this.DistributeInternalSelection();
  }

  private void m_targetOperationGrid_TreeSelectionChanged(
    object sender,
    TreeSelectionChangedEventArgs e)
  {
    this.DistributeInternalSelection();
  }

  private void m_targetOperationGrid_AfterEdit(object sender, RowColEventArgs e)
  {
    if (!(((C1FlexGridBase) this.m_targetOperationGrid).Cols[e.Col].Name == "Merge"))
      return;
    CheckEnum cellCheck = ((C1FlexGridBase) this.m_targetOperationGrid).GetCellCheck(e.Row, e.Col);
    Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[e.Row].Node;
    if (node != null)
    {
      CUiROMTargetInfo key1 = node.Key as CUiROMTargetInfo;
      CUiROMRoboticTargetOperationInfo key2 = node.Key as CUiROMRoboticTargetOperationInfo;
      if (key1 != null)
        key1.ShouldMerge = cellCheck == 1;
      else if (key2 != null)
        key2.ShouldMerge = cellCheck == 1;
    }
    ((Control) this.m_executeButton).Enabled = this.ExecuteButtonEnabler();
    ((Control) this.m_previewButton).Enabled = this.IsAnyMergeMarked();
  }

  private void DistributeInternalSelection()
  {
    Cursor cursor = ((Control) this).Cursor;
    try
    {
      this.m_isInternalSelection = true;
      TxObjectList txObjectList = new TxObjectList();
      List<int> selectedTreeRows1 = this.m_sourceOperationGrid.SelectedTreeRows;
      if (selectedTreeRows1 != null)
      {
        foreach (int num in selectedTreeRows1)
        {
          Node node = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[num].Node;
          if (node != null && node.Key is CUiROMGridNodeInfo key)
          {
            ITxObject nodeObject = key.NodeObject;
            if (nodeObject != null && !((Collection<ITxObject>) txObjectList).Contains(nodeObject))
              ((Collection<ITxObject>) txObjectList).Add(nodeObject);
          }
        }
      }
      List<int> selectedTreeRows2 = this.m_targetOperationGrid.SelectedTreeRows;
      if (selectedTreeRows2 != null)
      {
        foreach (int num in selectedTreeRows2)
        {
          Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[num].Node;
          if (node != null && node.Key is CUiROMGridNodeInfo key)
          {
            bool flag = false;
            if (key is CUiROMTargetInfo cuiRomTargetInfo && !cuiRomTargetInfo.BelongToTarget)
              flag = true;
            if (!flag)
            {
              ITxObject nodeObject = key.NodeObject;
              if (nodeObject != null && !((Collection<ITxObject>) txObjectList).Contains(nodeObject))
                ((Collection<ITxObject>) txObjectList).Add(nodeObject);
            }
          }
        }
      }
      TxSelection activeSelection = TxApplication.ActiveSelection;
      ((Control) this).Cursor = Cursors.WaitCursor;
      activeSelection.SetItems(txObjectList);
      if (this.m_isEmphasizeMode)
        this.EmphasizeTargetSelection();
      ((Control) this).Cursor = cursor;
      this.UpdateOnSelectionButtonEnablers();
    }
    catch (Exception ex)
    {
      this.m_isInternalSelection = false;
      ((Control) this).Cursor = cursor;
      this.UpdateAllButtonEnablers();
    }
  }

  private void UpdateTargetDistanceColumnCaption(string unitName)
  {
    if (unitName == null || !((C1FlexGridBase) this.m_targetOperationGrid).Cols.Contains("Distance"))
      return;
    string caption = ((C1FlexGridBase) this.m_targetOperationGrid).Cols["Distance"].Caption;
    int num = caption.IndexOf('(');
    int startIndex = caption.IndexOf(')');
    ((C1FlexGridBase) this.m_targetOperationGrid).Cols["Distance"].Caption = num < 0 || startIndex <= num ? $"{caption} ({unitName})" : caption.Substring(0, num + 1) + unitName + caption.Substring(startIndex);
  }

  private bool LoadDefaultSettings()
  {
    bool flag1 = true;
    try
    {
      string outputValue1 = (string) null;
      string outputValue2 = (string) null;
      string outputValue3 = (string) null;
      string outputValue4 = (string) null;
      string outputValue5 = (string) null;
      string outputValue6 = (string) null;
      string outputValue7 = (string) null;
      string outputValue8 = (string) null;
      string outputValue9 = (string) null;
      string outputValue10 = (string) null;
      bool flag2 = this.LoadFormStringValue((Form) this, "MergeSettings", "CopyDefaultPosition", out outputValue1) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyDefaultOrientationAll", out outputValue2) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyDefaultOrientationExceptPerpendicular", out outputValue3) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyDefaultExternalAxis", out outputValue4) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyDefaultTaught", out outputValue5) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyDefaultRobotConfiguration", out outputValue6) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyDefaultRoboticParameters", out outputValue7) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyDefaultOlpCommands", out outputValue8) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyDefaultAttributes", out outputValue9) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyDefaultName", out outputValue10);
      this.m_areSettingsLoaded = flag2;
      if (flag2)
      {
        CUiROMMergeSettings.CopyDefaultPosition = outputValue1 == null || !outputValue1.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyDefaultOrientationAll = outputValue2 == null || !outputValue2.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyDefaultOrientationExceptPerpendicular = outputValue3 == null || !outputValue3.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyDefaultExternalAxis = outputValue4 == null || !outputValue4.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyDefaultTaught = outputValue5 == null || !outputValue5.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyDefaultRobotConfiguration = outputValue6 == null || !outputValue6.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyDefaultRoboticParameters = outputValue7 == null || !outputValue7.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyDefaultOlpCommands = outputValue8 == null || !outputValue8.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyDefaultAttributes = outputValue9 == null || !outputValue9.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyDefaultName = outputValue10 == null || !outputValue10.Equals("False", StringComparison.InvariantCultureIgnoreCase);
      }
    }
    catch (Exception ex)
    {
      flag1 = false;
      this.m_areSettingsLoaded = false;
    }
    return flag1;
  }

  private bool LoadAlternateSettings()
  {
    bool flag1 = true;
    try
    {
      string outputValue1 = (string) null;
      string outputValue2 = (string) null;
      string outputValue3 = (string) null;
      string outputValue4 = (string) null;
      string outputValue5 = (string) null;
      string outputValue6 = (string) null;
      string outputValue7 = (string) null;
      string outputValue8 = (string) null;
      string outputValue9 = (string) null;
      string outputValue10 = (string) null;
      bool flag2 = this.LoadFormStringValue((Form) this, "MergeSettings", "CopyAlternatePosition", out outputValue1) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyAlternateOrientationAll", out outputValue2) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyAlternateOrientationExceptPerpendicular", out outputValue3) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyAlternateExternalAxis", out outputValue4) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyAlternateTaught", out outputValue5) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyAlternateRobotConfiguration", out outputValue6) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyAlternateRoboticParameters", out outputValue7) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyAlternateOlpCommands", out outputValue8) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyAlternateAttributes", out outputValue9) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyAlternateName", out outputValue10);
      this.m_areSettingsLoaded = flag2;
      if (flag2)
      {
        CUiROMMergeSettings.CopyAlternatePosition = outputValue1 == null || !outputValue1.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyAlternateOrientationAll = outputValue2 == null || !outputValue2.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyAlternateOrientationExceptPerpendicular = outputValue3 == null || !outputValue3.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyAlternateExternalAxis = outputValue4 == null || !outputValue4.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyAlternateTaught = outputValue5 == null || !outputValue5.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyAlternateRobotConfiguration = outputValue6 == null || !outputValue6.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyAlternateRoboticParameters = outputValue7 == null || !outputValue7.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyAlternateOlpCommands = outputValue8 == null || !outputValue8.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyAlternateAttributes = outputValue9 == null || !outputValue9.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyAlternateName = outputValue10 == null || !outputValue10.Equals("False", StringComparison.InvariantCultureIgnoreCase);
      }
    }
    catch (Exception ex)
    {
      flag1 = false;
      this.m_areSettingsLoaded = false;
    }
    return flag1;
  }

  private bool LoadViaSettings()
  {
    bool flag1 = true;
    try
    {
      string outputValue1 = (string) null;
      string outputValue2 = (string) null;
      string outputValue3 = (string) null;
      string outputValue4 = (string) null;
      string str = (string) null;
      string outputValue5 = (string) null;
      string outputValue6 = (string) null;
      string outputValue7 = (string) null;
      string outputValue8 = (string) null;
      string outputValue9 = (string) null;
      bool flag2 = this.LoadFormStringValue((Form) this, "MergeSettings", "CopyViaPosition", out outputValue1) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyViaOrientationAll", out outputValue2) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyViaExternalAxis", out outputValue3) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyViaTaught", out outputValue4) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyViaRobotConfiguration", out outputValue5) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyViaRoboticParameters", out outputValue6) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyViaOlpCommands", out outputValue7) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyViaAttributes", out outputValue8) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyViaName", out outputValue9);
      this.m_areSettingsLoaded = flag2;
      if (flag2)
      {
        CUiROMMergeSettings.CopyViaPosition = outputValue1 == null || !outputValue1.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyViaOrientationAll = outputValue2 == null || !outputValue2.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyViaExternalAxis = outputValue3 == null || !outputValue3.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyViaTaught = outputValue4 == null || !outputValue4.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyViaTaughtOrientationAll = str == null || !str.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyViaRobotConfiguration = outputValue5 == null || !outputValue5.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyViaRoboticParameters = outputValue6 == null || !outputValue6.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyViaOlpCommands = outputValue7 == null || !outputValue7.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyViaAttributes = outputValue8 == null || !outputValue8.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyViaName = outputValue9 == null || !outputValue9.Equals("False", StringComparison.InvariantCultureIgnoreCase);
      }
    }
    catch (Exception ex)
    {
      flag1 = false;
      this.m_areSettingsLoaded = false;
    }
    return flag1;
  }

  private bool LoadOperationSettings()
  {
    bool flag1 = true;
    try
    {
      string outputValue1 = (string) null;
      string outputValue2 = (string) null;
      string outputValue3 = (string) null;
      string outputValue4 = (string) null;
      bool flag2 = this.LoadFormStringValue((Form) this, "MergeSettings", "CopyOperationRoboticParameters", out outputValue1) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyOperationOlpCommands", out outputValue2) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyOperationAttributes", out outputValue3) & this.LoadFormStringValue((Form) this, "MergeSettings", "CopyOperationName", out outputValue4);
      this.m_areSettingsLoaded = flag2;
      if (flag2)
      {
        CUiROMMergeSettings.CopyOperationRoboticParameters = outputValue1 == null || !outputValue1.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyOperationOlpCommands = outputValue2 == null || !outputValue2.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyOperationAttributes = outputValue3 == null || !outputValue3.Equals("False", StringComparison.InvariantCultureIgnoreCase);
        CUiROMMergeSettings.CopyOperationName = outputValue4 == null || !outputValue4.Equals("False", StringComparison.InvariantCultureIgnoreCase);
      }
    }
    catch (Exception ex)
    {
      flag1 = false;
      this.m_areSettingsLoaded = false;
    }
    return flag1;
  }

  private bool LoadSettings()
  {
    bool flag1 = true;
    try
    {
      string outputValue1 = (string) null;
      string outputValue2 = (string) null;
      string outputValue3 = (string) null;
      string outputValue4 = (string) null;
      bool flag2 = this.LoadFormStringValue((Form) this, "AutomaticMatchSettings", "AutomaticMatchCriteria", out outputValue1) & this.LoadFormStringValue((Form) this, "AutomaticMatchSettings", "AutomaticMatchMaxDistance", out outputValue2) & this.LoadFormStringValue((Form) this, "AutomaticMatchSettings", "MatchByDistanceWithMaxDeviation", out outputValue3) & this.LoadFormStringValue((Form) this, "AutomaticMatchSettings", "MatchByNameCaseSensitive", out outputValue4);
      if (flag2)
      {
        switch (outputValue1)
        {
          case "MatchByName":
            CUiROMAutomaticMatchSettings.Criteria = CUiROMDataUtils.AutomaticMatchCriteria.MatchByName;
            break;
          case "MatchByDistanceWithMaxDeviation":
            CUiROMAutomaticMatchSettings.Criteria = CUiROMDataUtils.AutomaticMatchCriteria.MatchByDistanceWithMaxDeviation;
            break;
          default:
            CUiROMAutomaticMatchSettings.Criteria = CUiROMDataUtils.AutomaticMatchCriteria.MatchByDistance;
            break;
        }
        if (outputValue2 != null)
        {
          double result = 0.0;
          CultureInfo provider = new CultureInfo("en-US");
          CUiROMAutomaticMatchSettings.MaximumDistance = !double.TryParse(outputValue2, NumberStyles.AllowDecimalPoint, (IFormatProvider) provider, out result) ? 0.0 : result;
        }
        if (outputValue3 != null)
        {
          double result = 0.0;
          CultureInfo provider = new CultureInfo("en-US");
          CUiROMAutomaticMatchSettings.MaximumDeviation = !double.TryParse(outputValue3, NumberStyles.AllowDecimalPoint, (IFormatProvider) provider, out result) ? 0.0 : result;
        }
        CUiROMAutomaticMatchSettings.MatchByNameCaseSensitive = outputValue4 != null && outputValue4.Equals("True", StringComparison.InvariantCultureIgnoreCase);
      }
      bool flag3 = flag2 & this.LoadDefaultSettings() & this.LoadAlternateSettings() & this.LoadViaSettings() & this.LoadOperationSettings();
      string outputValue5 = (string) null;
      bool flag4 = flag3 & this.LoadFormStringValue((Form) this, "AutomaticLogSettings", "ShowLogAutomatic", out outputValue5);
      if (flag4)
        this.m_automaticLogSettings.ShowLogAutomatic = outputValue5 != null && outputValue5.Equals("True", StringComparison.InvariantCultureIgnoreCase);
      this.m_areSettingsLoaded &= flag4;
    }
    catch (Exception ex)
    {
      flag1 = false;
      this.m_areSettingsLoaded = false;
    }
    return flag1;
  }

  private bool LoadFormStringValue(
    Form form,
    string collectionRelativePath,
    string propName,
    out string outputValue)
  {
    bool flag = true;
    outputValue = (string) null;
    try
    {
      if (form != null && collectionRelativePath != null && propName != null)
      {
        object obj = (object) null;
        TxFormSettings.RestoreFormValue(form, collectionRelativePath, propName, ref obj);
        if (obj != null)
          outputValue = obj as string;
        else
          flag = false;
      }
      else
        flag = false;
    }
    catch (Exception ex)
    {
      outputValue = (string) null;
      flag = false;
    }
    return flag;
  }

  private bool StoreDefaultSettings()
  {
    bool flag = true;
    try
    {
      string propValue1 = !CUiROMMergeSettings.CopyDefaultPosition ? "False" : "True";
      string propValue2 = !CUiROMMergeSettings.CopyDefaultOrientationAll ? "False" : "True";
      string propValue3 = !CUiROMMergeSettings.CopyDefaultOrientationExceptPerpendicular ? "False" : "True";
      string propValue4 = !CUiROMMergeSettings.CopyDefaultExternalAxis ? "False" : "True";
      string propValue5 = !CUiROMMergeSettings.CopyDefaultTaught ? "False" : "True";
      string propValue6 = !CUiROMMergeSettings.CopyDefaultRobotConfiguration ? "False" : "True";
      string propValue7 = !CUiROMMergeSettings.CopyDefaultRoboticParameters ? "False" : "True";
      string propValue8 = !CUiROMMergeSettings.CopyDefaultOlpCommands ? "False" : "True";
      string propValue9 = !CUiROMMergeSettings.CopyDefaultAttributes ? "False" : "True";
      string propValue10 = !CUiROMMergeSettings.CopyDefaultName ? "False" : "True";
      return flag & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyDefaultPosition", propValue1) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyDefaultOrientationAll", propValue2) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyDefaultOrientationExceptPerpendicular", propValue3) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyDefaultExternalAxis", propValue4) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyDefaultTaught", propValue5) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyDefaultRobotConfiguration", propValue6) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyDefaultRoboticParameters", propValue7) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyDefaultOlpCommands", propValue8) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyDefaultAttributes", propValue9) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyDefaultName", propValue10);
    }
    catch (Exception ex)
    {
      return false;
    }
  }

  private bool StoreAlternateSettings()
  {
    bool flag = true;
    try
    {
      string propValue1 = !CUiROMMergeSettings.CopyAlternatePosition ? "False" : "True";
      string propValue2 = !CUiROMMergeSettings.CopyAlternateOrientationAll ? "False" : "True";
      string propValue3 = !CUiROMMergeSettings.CopyAlternateOrientationExceptPerpendicular ? "False" : "True";
      string propValue4 = !CUiROMMergeSettings.CopyAlternateExternalAxis ? "False" : "True";
      string propValue5 = !CUiROMMergeSettings.CopyAlternateTaught ? "False" : "True";
      string propValue6 = !CUiROMMergeSettings.CopyAlternateRobotConfiguration ? "False" : "True";
      string propValue7 = !CUiROMMergeSettings.CopyAlternateRoboticParameters ? "False" : "True";
      string propValue8 = !CUiROMMergeSettings.CopyAlternateOlpCommands ? "False" : "True";
      string propValue9 = !CUiROMMergeSettings.CopyAlternateAttributes ? "False" : "True";
      string propValue10 = !CUiROMMergeSettings.CopyAlternateName ? "False" : "True";
      return flag & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyAlternatePosition", propValue1) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyAlternateOrientationAll", propValue2) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyAlternateOrientationExceptPerpendicular", propValue3) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyAlternateExternalAxis", propValue4) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyAlternateTaught", propValue5) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyAlternateRobotConfiguration", propValue6) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyAlternateRoboticParameters", propValue7) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyAlternateOlpCommands", propValue8) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyAlternateAttributes", propValue9) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyAlternateName", propValue10);
    }
    catch (Exception ex)
    {
      return false;
    }
  }

  private bool StoreViaSettings()
  {
    bool flag = true;
    try
    {
      string propValue1 = !CUiROMMergeSettings.CopyViaPosition ? "False" : "True";
      string propValue2 = !CUiROMMergeSettings.CopyViaOrientationAll ? "False" : "True";
      string propValue3 = !CUiROMMergeSettings.CopyViaExternalAxis ? "False" : "True";
      string propValue4 = !CUiROMMergeSettings.CopyViaTaught ? "False" : "True";
      string propValue5 = !CUiROMMergeSettings.CopyViaRobotConfiguration ? "False" : "True";
      string propValue6 = !CUiROMMergeSettings.CopyViaRoboticParameters ? "False" : "True";
      string propValue7 = !CUiROMMergeSettings.CopyViaOlpCommands ? "False" : "True";
      string propValue8 = !CUiROMMergeSettings.CopyViaAttributes ? "False" : "True";
      string propValue9 = !CUiROMMergeSettings.CopyViaName ? "False" : "True";
      return flag & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyViaPosition", propValue1) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyViaOrientationAll", propValue2) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyViaExternalAxis", propValue3) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyViaTaught", propValue4) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyViaRobotConfiguration", propValue5) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyViaRoboticParameters", propValue6) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyViaOlpCommands", propValue7) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyViaAttributes", propValue8) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyViaName", propValue9);
    }
    catch (Exception ex)
    {
      return false;
    }
  }

  private bool StoreOperationSettings()
  {
    bool flag = true;
    try
    {
      string propValue1 = !CUiROMMergeSettings.CopyOperationRoboticParameters ? "False" : "True";
      string propValue2 = !CUiROMMergeSettings.CopyOperationOlpCommands ? "False" : "True";
      string propValue3 = !CUiROMMergeSettings.CopyOperationAttributes ? "False" : "True";
      string propValue4 = !CUiROMMergeSettings.CopyOperationName ? "False" : "True";
      return flag & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyOperationRoboticParameters", propValue1) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyOperationOlpCommands", propValue2) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyOperationAttributes", propValue3) & this.StoreFormStringValue((Form) this, "MergeSettings", "CopyOperationName", propValue4);
    }
    catch (Exception ex)
    {
      return false;
    }
  }

  private bool StoreSettings()
  {
    try
    {
      string propValue1;
      switch (CUiROMAutomaticMatchSettings.Criteria)
      {
        case CUiROMDataUtils.AutomaticMatchCriteria.MatchByName:
          propValue1 = "MatchByName";
          break;
        case CUiROMDataUtils.AutomaticMatchCriteria.MatchByDistanceWithMaxDeviation:
          propValue1 = "MatchByDistanceWithMaxDeviation";
          break;
        default:
          propValue1 = "MatchByDistance";
          break;
      }
      CultureInfo provider = new CultureInfo("en-US");
      double num = CUiROMAutomaticMatchSettings.MaximumDistance;
      string propValue2 = num.ToString("0.00", (IFormatProvider) provider);
      num = CUiROMAutomaticMatchSettings.MaximumDeviation;
      string propValue3 = num.ToString("0.00000", (IFormatProvider) provider);
      string propValue4 = !CUiROMAutomaticMatchSettings.MatchByNameCaseSensitive ? "False" : "True";
      return this.StoreFormStringValue((Form) this, "AutomaticMatchSettings", "AutomaticMatchCriteria", propValue1) & this.StoreFormStringValue((Form) this, "AutomaticMatchSettings", "AutomaticMatchMaxDistance", propValue2) & this.StoreFormStringValue((Form) this, "AutomaticMatchSettings", "MatchByDistanceWithMaxDeviation", propValue3) & this.StoreFormStringValue((Form) this, "AutomaticMatchSettings", "MatchByNameCaseSensitive", propValue4) & this.StoreDefaultSettings() & this.StoreAlternateSettings() & this.StoreViaSettings() & this.StoreOperationSettings() & this.StoreFormStringValue((Form) this, "AutomaticLogSettings", "ShowLogAutomatic", !this.m_automaticLogSettings.ShowLogAutomatic ? "False" : "True");
    }
    catch (Exception ex)
    {
      return false;
    }
  }

  private bool StoreFormStringValue(
    Form form,
    string collectionRelativePath,
    string propName,
    string propValue)
  {
    bool flag = true;
    try
    {
      if (form != null && collectionRelativePath != null && propName != null && propValue != null)
        TxFormSettings.StoreFormValue(form, collectionRelativePath, propName, propValue);
      else
        flag = false;
    }
    catch (Exception ex)
    {
      flag = false;
    }
    return flag;
  }

  internal static TxColor SourceEmphasizeColor
  {
    get => CUiROMMainForm.GetEmphasizeColor(CUiROMDataUtils.SOURCE_STATUS_COLOR);
  }

  internal static TxColor TargetEmphasizeColor
  {
    get => CUiROMMainForm.GetEmphasizeColor(CUiROMDataUtils.TARGET_STATUS_COLOR);
  }

  internal static TxColor GetEmphasizeColor(string statusColorKey)
  {
    Color color = TxStatusColor.Background(statusColorKey);
    return new TxColor(color.R, color.G, color.B);
  }

  private void EmphasizeTargetSelection()
  {
    List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
    this.ClearAllEmphasizedPairs(false);
    for (int index = 0; index < selectedTreeRows.Count; ++index)
    {
      Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[selectedTreeRows[index]].Node;
      if (node != null && !this.IsNodeOfTypeSeamOperation(selectedTreeRows[index]) && node.Key is CUiROMTargetInfo key && key.MatchedObject != null)
      {
        if (key.BelongToTarget)
          this.EmphasizePair(key.NodeObject, key.MatchedObject);
        else
          this.EmphasizePair((ITxObject) null, key.MatchedObject);
      }
    }
    TxApplication.RefreshDisplay();
  }

  private void EmphasizePair(ITxObject targetLocation, ITxObject sourceLocation)
  {
    if (targetLocation != null && targetLocation != sourceLocation && targetLocation is ITxDisplayableObject displayableObject1)
    {
      TxDisplayableObjectEx.EmphasizeObject(displayableObject1, CUiROMMainForm.TargetEmphasizeColor, (TxColorEmphasizePriority) 1);
      this.m_emphasizedTargetLocations.Add(targetLocation);
    }
    if (sourceLocation == null || !(sourceLocation is ITxDisplayableObject displayableObject2))
      return;
    TxDisplayableObjectEx.EmphasizeObject(displayableObject2, CUiROMMainForm.SourceEmphasizeColor, (TxColorEmphasizePriority) 1);
    this.m_emphasizedMatchedLocations.Add(sourceLocation);
  }

  private void UnEmphasizePair(ITxObject targetLocation, ITxObject sourceLocation)
  {
    if (targetLocation != null && targetLocation != sourceLocation && targetLocation is ITxDisplayableObject displayableObject1 && this.m_emphasizedTargetLocations.Contains(targetLocation))
    {
      this.m_emphasizedTargetLocations.Remove(targetLocation);
      if (!this.m_emphasizedTargetLocations.Contains(targetLocation))
        TxDisplayableObjectEx.StopEmphasizeObject(displayableObject1, CUiROMMainForm.TargetEmphasizeColor, (TxColorEmphasizePriority) 1);
    }
    if (sourceLocation == null || !(sourceLocation is ITxDisplayableObject displayableObject2) || !this.m_emphasizedMatchedLocations.Contains(sourceLocation))
      return;
    this.m_emphasizedMatchedLocations.Remove(sourceLocation);
    if (this.m_emphasizedMatchedLocations.Contains(sourceLocation))
      return;
    TxDisplayableObjectEx.EmphasizeObject(displayableObject2, CUiROMMainForm.SourceEmphasizeColor, (TxColorEmphasizePriority) 1);
  }

  private void ClearAllEmphasizedPairs(bool refreshDisplay)
  {
    for (int index = this.m_emphasizedTargetLocations.Count - 1; index >= 0; --index)
    {
      ITxObject emphasizedTargetLocation = this.m_emphasizedTargetLocations[index];
      if (emphasizedTargetLocation != null && emphasizedTargetLocation is ITxDisplayableObject displayableObject)
      {
        this.m_emphasizedTargetLocations.RemoveAt(index);
        if (!this.m_emphasizedTargetLocations.Contains(emphasizedTargetLocation))
          TxDisplayableObjectEx.StopEmphasizeObject(displayableObject, CUiROMMainForm.TargetEmphasizeColor, (TxColorEmphasizePriority) 1);
      }
    }
    for (int index = this.m_emphasizedMatchedLocations.Count - 1; index >= 0; --index)
    {
      ITxObject emphasizedMatchedLocation = this.m_emphasizedMatchedLocations[index];
      if (emphasizedMatchedLocation != null && emphasizedMatchedLocation is ITxDisplayableObject displayableObject)
      {
        this.m_emphasizedMatchedLocations.RemoveAt(index);
        if (!this.m_emphasizedMatchedLocations.Contains(emphasizedMatchedLocation))
          TxDisplayableObjectEx.StopEmphasizeObject(displayableObject, CUiROMMainForm.SourceEmphasizeColor, (TxColorEmphasizePriority) 1);
      }
    }
    this.m_emphasizedTargetLocations.Clear();
    this.m_emphasizedMatchedLocations.Clear();
    if (!refreshDisplay)
      return;
    TxApplication.RefreshDisplay();
  }

  private void m_selectOperationsForm_FormClosed(object sender, FormClosedEventArgs e)
  {
    ((Form) this.m_selectOperationsForm).FormClosed -= new FormClosedEventHandler(this.m_selectOperationsForm_FormClosed);
    if (!this.m_selectOperationsForm.AcceptChanges)
      return;
    this.m_acceptSelectedOperations = true;
    this.m_selectedTargetOperation = this.m_selectOperationsForm.TargetOperation;
    this.m_selectedSourceOperation = this.m_selectOperationsForm.SourceOperation;
  }

  private void m_selectOperationsForm_Disposed(object sender, EventArgs e)
  {
    this.m_selectOperationsForm = (CUiROMSelectOperationsForm) null;
    if (this.m_acceptSelectedOperations && (this.m_targetOperation != null || this.m_sourceOperation != null))
      this.m_acceptSelectedOperations = TxMessageBox.Show(this.GetResourceManager().GetString("WARNING_GRIDS_DATA_UPDATE"), this.GetResourceManager().GetString("WARNING_CAPTION"), MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes;
    if (!((Control) this).Visible)
      ((Control) this).Visible = true;
    if (this.m_acceptSelectedOperations)
    {
      this.m_targetOperation = this.m_selectedTargetOperation;
      this.m_sourceOperation = this.m_selectedSourceOperation;
      this.m_observerManager.UnRegisterObservedObjects();
      this.InitGrids();
      this.ComputeWeldContainer();
    }
    else
      this.UpdateAllButtonEnablers();
  }

  private ResourceManager GetResourceManager()
  {
    return new ResourceManager("DnProcessSimulateCommands.RoboticOperationMerge.Res.ResourceTable", ((object) this).GetType().Assembly);
  }

  private void m_observerManager_OnObservedObjectChanged(
    object sender,
    ObservedObjectChangedEventArgs e)
  {
    switch (e.ObservedObjectAction)
    {
      case ObservedObjectAction.Deleted:
        if (this.m_targetOperation == e.NodeObject)
        {
          this.UnRegisterTargetGridObjects();
          this.m_targetOperation = (ITxObject) null;
          this.InitGrids();
          break;
        }
        if (this.m_sourceOperation == e.NodeObject)
        {
          this.UnRegisterSourceGridObjects();
          this.m_sourceOperation = (ITxObject) null;
          this.InitGrids();
          break;
        }
        this.RemoveLocationObjects(e.NodeObject, e.RelatedObjects);
        break;
      case ObservedObjectAction.NameChanged:
        this.ChangeNameInAffectedRows(e.NodeObject);
        break;
      case ObservedObjectAction.ItemsRemoved:
        this.RemoveLocationObjects(e.NodeObject, e.RelatedObjects);
        break;
    }
    this.UpdateAllButtonEnablers();
  }

  private void ChangeNameInAffectedRows(ITxObject nodeObject)
  {
    if (nodeObject == null)
      return;
    if (this.m_targetOperation == nodeObject)
    {
      Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[1].Node;
      if (node == null || !(node.Key is CUiROMRoboticTargetOperationInfo key) || key.NodeObject == null)
        return;
      key.NiceName = key.NodeObject.Name;
      ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
      this.m_targetOperationGrid.UpdateRows(1, 1, false);
      ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
    }
    else if (this.m_sourceOperation == nodeObject)
    {
      Node node1 = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[1].Node;
      if (node1 != null && node1.Key is CUiROMRoboticTargetOperationInfo key1 && key1.NodeObject != null)
      {
        key1.NiceName = key1.NodeObject.Name;
        ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
        this.m_targetOperationGrid.UpdateRows(1, 1, false);
        ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
      }
      Node node2 = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[1].Node;
      if (node2 == null || !(node2.Key is CUiROMRoboticSourceOperationInfo key2) || key2.NodeObject == null)
        return;
      key2.NiceName = key2.NodeObject.Name;
      ((ScrollableControl) this.m_sourceOperationGrid).BeginUpdate();
      this.m_sourceOperationGrid.UpdateRows(1, 1, false);
      ((ScrollableControl) this.m_sourceOperationGrid).EndUpdate();
    }
    else
    {
      ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
      for (int rowIndex = 2; rowIndex < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count; ++rowIndex)
      {
        Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[rowIndex].Node;
        if (node != null && node.Key is CUiROMTargetInfo key && (key.NodeObject == nodeObject || key.MatchedObject == nodeObject))
        {
          if (key.NodeObject == nodeObject)
            key.NiceName = key.NodeObject.Name;
          this.m_targetOperationGrid.UpdateRows(rowIndex, 1, false);
        }
      }
      ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
      ((ScrollableControl) this.m_sourceOperationGrid).BeginUpdate();
      for (int rowIndex = 2; rowIndex < ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count; ++rowIndex)
      {
        Node node = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[rowIndex].Node;
        if (node != null && node.Key is CUiROMSourceInfo key && key.NodeObject == nodeObject)
        {
          key.NiceName = key.NodeObject.Name;
          this.m_sourceOperationGrid.UpdateRows(rowIndex, 1, false);
        }
      }
      ((ScrollableControl) this.m_sourceOperationGrid).EndUpdate();
    }
  }

  private void RemoveLocationObjects(ITxObject oldParent, TxObjectList removedObjs)
  {
    if (removedObjs == null || ((Collection<ITxObject>) removedObjs).Count <= 0)
      return;
    List<int> rows = new List<int>();
    List<CUiROMTargetInfo> childList = new List<CUiROMTargetInfo>();
    TxObjectList txObjectList = new TxObjectList();
    bool flag = false;
    for (int index = 2; index < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count; ++index)
    {
      Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[index].Node;
      if (node != null && node.Key is CUiROMTargetInfo key && (((Collection<ITxObject>) removedObjs).Contains(key.NodeObject) || ((Collection<ITxObject>) removedObjs).Contains(key.MatchedObject)))
      {
        if (this.m_isEmphasizeMode && !this.IsNodeOfTypeSeamOperation(index))
        {
          if (key.BelongToTarget)
            this.UnEmphasizePair(key.NodeObject, key.MatchedObject);
          else
            this.UnEmphasizePair((ITxObject) null, key.MatchedObject);
        }
        if (((Collection<ITxObject>) removedObjs).Contains(key.NodeObject))
        {
          if (!key.BelongToTarget || oldParent == this.m_targetOperation)
          {
            childList.Add(key);
            rows.Add(index);
            if (key.MatchedObject != null && !((Collection<ITxObject>) txObjectList).Contains(key.MatchedObject))
              ((Collection<ITxObject>) txObjectList).Add(key.MatchedObject);
          }
        }
        else
        {
          key.MatchedObject = (ITxObject) null;
          key.ShouldMerge = false;
          flag = true;
        }
      }
    }
    if (childList.Count > 0)
    {
      this.m_dataManager.RemoveTargetChildren(childList);
      ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
      this.m_targetOperationGrid.RemoveRows(rows, true);
      ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
      this.m_isTargetLocationChanged = true;
    }
    rows.Clear();
    List<CUiROMSourceInfo> locationsList = new List<CUiROMSourceInfo>();
    for (int index = 2; index < ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count; ++index)
    {
      Node node = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[index].Node;
      if (node != null && node.Key is CUiROMSourceInfo key && ((Collection<ITxObject>) removedObjs).Contains(key.NodeObject) && oldParent == this.m_sourceOperation)
      {
        locationsList.Add(key);
        rows.Add(index);
      }
    }
    if (locationsList.Count > 0)
    {
      this.m_dataManager.RemoveSourceChildren(locationsList);
      ((ScrollableControl) this.m_sourceOperationGrid).BeginUpdate();
      this.m_sourceOperationGrid.RemoveRows(rows, true);
      ((ScrollableControl) this.m_sourceOperationGrid).EndUpdate();
    }
    if (flag)
    {
      ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
      this.m_targetOperationGrid.UpdateRows(2, ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count - 2, false);
      ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
    }
    if (((Collection<ITxObject>) txObjectList).Count <= 0)
      return;
    foreach (ITxObject matchedObject in (Collection<ITxObject>) txObjectList)
      this.m_dataManager.RefreshMatchedIndication(matchedObject);
    ((ScrollableControl) this.m_sourceOperationGrid).BeginUpdate();
    this.m_sourceOperationGrid.UpdateRows(2, ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count - 2, false);
    ((ScrollableControl) this.m_sourceOperationGrid).EndUpdate();
  }

  private void RegisterTargetGridObjects()
  {
    for (int index = 1; index < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count; ++index)
    {
      Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[index].Node;
      if (node != null && node.Key is CUiROMGridNodeInfo key && key.NodeObject != null)
        this.m_observerManager.RegisterObject(key.NodeObject);
    }
  }

  private void UnRegisterTargetGridObjects()
  {
    for (int index = 1; index < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count; ++index)
    {
      Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[index].Node;
      if (node != null && node.Key is CUiROMGridNodeInfo key && key.NodeObject != null)
        this.m_observerManager.UnRegisterObject(key.NodeObject);
    }
  }

  private void RegisterSourceGridObjects()
  {
    for (int index = 1; index < ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count; ++index)
    {
      Node node = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[index].Node;
      if (node != null && node.Key is CUiROMGridNodeInfo key && key.NodeObject != null)
        this.m_observerManager.RegisterObject(key.NodeObject);
    }
  }

  private void UnRegisterSourceGridObjects()
  {
    for (int index = 1; index < ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count; ++index)
    {
      Node node = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[index].Node;
      if (node != null && node.Key is CUiROMGridNodeInfo key && key.NodeObject != null)
        this.m_observerManager.UnRegisterObject(key.NodeObject);
    }
  }

  private bool AskAboutExcelLog(out bool confirmed)
  {
    bool flag = false;
    confirmed = false;
    string str1 = this.GetResourceManager().GetString("SHOW_LOG_TEXT");
    string str2 = this.GetResourceManager().GetString("QUESTION_CAPTION");
    if (str1 != null && str2 != null)
    {
      if (TxMessageBox.Show(str1, str2, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
        confirmed = true;
      flag = true;
    }
    return flag;
  }

  private bool NotifyAboutUnableToAddLocations()
  {
    bool addLocations = false;
    string str1 = this.GetResourceManager().GetString("UNABLE_TO_ADD_TEXT");
    string str2 = this.GetResourceManager().GetString("ERROR_CAPTION");
    if (str1 != null && str2 != null)
    {
      int num = (int) TxMessageBox.Show(str1, str2, MessageBoxButtons.OK, MessageBoxIcon.Hand);
      addLocations = true;
    }
    return addLocations;
  }

  private bool IsNodeOfTypeViaLocation(int index)
  {
    Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[index].Node;
    return node != null && node.Key is CUiROMTargetInfo key && key.NodeObject is TxRoboticViaLocationOperation;
  }

  private bool IsNodeOfTypeSeamOperation(int index)
  {
    Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[index].Node;
    return node != null && node.Key is CUiROMTargetInfo key && key.NodeObject is TxRoboticSeamOperation;
  }

  private bool IsNodeOfTypeOperation(int index)
  {
    Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[index].Node;
    return node != null && node.Key is CUiROMTargetInfo key && (key.NodeObject is TxRoboticSeamOperation || key.NodeObject is ITxContinuousOperation || key.NodeObject is TxGenericRoboticOperation || key.NodeObject is ITxWeldOperation);
  }

  private bool IsNodeOfTypeSeamLocation(int index)
  {
    Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[index].Node;
    return node != null && node.Key is CUiROMTargetInfo key && key.NodeObject is TxRoboticSeamLocationOperation;
  }

  private bool IsSourceNodeOfTypeOperation(int index)
  {
    Node node = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[index].Node;
    return node != null && node.Key is CUiROMSourceInfo key && (key.NodeObject is TxRoboticSeamOperation || key.NodeObject is ITxContinuousOperation || key.NodeObject is TxGenericRoboticOperation || key.NodeObject is ITxWeldOperation);
  }

  private bool IsSourceNodeOfTypeSeamLocation(int index)
  {
    Node node = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[index].Node;
    return node != null && node.Key is CUiROMSourceInfo key && key.NodeObject is TxRoboticSeamLocationOperation;
  }

  private bool IsSourceNodeOfTypeViaLocation(int index)
  {
    Node node = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[index].Node;
    return node != null && node.Key is CUiROMSourceInfo key && key.NodeObject is TxRoboticViaLocationOperation;
  }

  private bool IsSourceNodeEmpty(int index)
  {
    Node node = ((C1FlexGridBase) this.m_sourceOperationGrid).Rows[index].Node;
    return node != null && node.Key is CUiROMGridNodeInfo key && key.NodeType == CUiROMDataUtils.NodeType.NotSet;
  }

  private bool CanNodeBeMovedDownInContOp(int index)
  {
    if (this.IsNodeOfTypeSeamLocation(index))
      return false;
    return this.IsNodeOfTypeViaLocation(index) ? index != ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count : this.IsNodeOfTypeSeamOperation(index) && index + this.CountNodesOfSeamOperation(index) < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count;
  }

  private bool CanNodeBeMovedUpInContOp(int index)
  {
    return !this.IsNodeOfTypeSeamLocation(index) && index != 1;
  }

  private int GetIndexOfSeamOperation(int seamLocIndex)
  {
    bool flag = false;
    int indexOfSeamOperation = 1;
    for (int index = seamLocIndex - 1; !flag && index > 0; --index)
    {
      if (this.IsNodeOfTypeSeamOperation(index))
      {
        flag = true;
        indexOfSeamOperation = index;
      }
    }
    return indexOfSeamOperation;
  }

  private int CountNodesOfSeamOperation(int seamOpIndex)
  {
    int num = 1;
    if (seamOpIndex == ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count)
      return num;
    bool flag = false;
    for (int index = seamOpIndex + 1; !flag && index < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count; ++index)
    {
      if (this.IsNodeOfTypeSeamOperation(index) || this.IsNodeOfTypeViaLocation(index))
        flag = true;
      else
        ++num;
    }
    if (!flag)
      num = ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count - seamOpIndex;
    return num;
  }

  private int CountNodesOfNextItemAfterSeamOperation(int seamOpIndex)
  {
    int num1 = 0;
    if (seamOpIndex == ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count)
      return num1;
    int num2 = this.CountNodesOfSeamOperation(seamOpIndex);
    if (seamOpIndex + num2 >= ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count)
      return num1;
    int seamOpIndex1 = seamOpIndex + num2;
    Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[seamOpIndex1].Node;
    if (node != null && node.Key is CUiROMTargetInfo key)
      num1 = !(key.NodeObject is TxRoboticViaLocationOperation) ? this.CountNodesOfSeamOperation(seamOpIndex1) : 1;
    return num1;
  }

  private int CountNodesOfNextItem(int startIndex)
  {
    if (startIndex == ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count)
      return 0;
    int num = 0;
    bool flag = false;
    for (int index = startIndex + 1; !flag && index < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count; ++index)
    {
      if (this.IsNodeOfTypeViaLocation(index))
      {
        num = 1;
        flag = true;
      }
      else if (this.IsNodeOfTypeSeamOperation(index))
      {
        num = this.CountNodesOfSeamOperation(index);
        flag = true;
      }
    }
    return num;
  }

  private int CountNodesOfPreviousItem(int startIndex)
  {
    if (startIndex <= 1)
      return 0;
    int num = 0;
    bool flag = false;
    for (int index = startIndex - 1; !flag && index > 0; --index)
    {
      if (this.IsNodeOfTypeViaLocation(index))
      {
        num = 1;
        flag = true;
      }
      else if (this.IsNodeOfTypeSeamOperation(index))
      {
        num = this.CountNodesOfSeamOperation(index);
        flag = true;
      }
    }
    return num;
  }

  private void AddSeamLocsOfSeamOpsToList(List<int> selectedRows)
  {
    for (int index1 = 0; index1 < selectedRows.Count; ++index1)
    {
      if (this.IsNodeOfTypeSeamOperation(selectedRows[index1]))
      {
        int num = this.CountNodesOfSeamOperation(selectedRows[index1]) - 1;
        for (int index2 = selectedRows[index1] + 1; index2 <= selectedRows[index1] + num; ++index2)
        {
          if (!selectedRows.Contains(index2))
            selectedRows.Add(index2);
        }
      }
    }
  }

  private bool NoSeamLocsOfSeamOpAreMatched(int i_seam_op)
  {
    bool flag1 = false;
    bool flag2 = false;
    for (int index = i_seam_op + 1; index < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count && !flag2 && !flag1; ++index)
    {
      if (this.IsNodeOfTypeSeamLocation(index))
      {
        Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[index].Node;
        if (node != null && node.Key is CUiROMTargetInfo key && key.BelongToTarget && key.MatchedObject != null)
          flag1 = true;
      }
      else
        flag2 = true;
    }
    return !flag1;
  }

  private CUiROMDataUtils.MergeSchema GetMergeSchemaAtRow(int i_row)
  {
    CUiROMDataUtils.MergeSchema mergeSchemaAtRow = CUiROMDataUtils.MergeSchema.LocDefault;
    Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[i_row].Node;
    if (node != null && node.Key is CUiROMGridNodeInfo)
      mergeSchemaAtRow = this.GetSchemaFromColumn(node.Key as CUiROMGridNodeInfo);
    return mergeSchemaAtRow;
  }

  private bool AtLeastOneLocIsMatched()
  {
    bool flag = false;
    for (int index = 2; !flag && index < ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count; ++index)
    {
      Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[index].Node;
      if (node != null && !this.IsNodeOfTypeOperation(index) && node.Key is CUiROMTargetInfo key && key.MatchedObject != null)
        flag = true;
    }
    return flag;
  }

  private void defaultToolStripMenuItem_Click(object sender, EventArgs e)
  {
    List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
    int count = ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count;
    foreach (int num in selectedTreeRows)
    {
      if (num > 0 && num < count)
      {
        Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[num].Node;
        if (node != null)
          this.SetMergeSchemaOfNode(node.Key as CUiROMGridNodeInfo);
      }
    }
    ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
    this.m_targetOperationGrid.UpdateRows(1, ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count - 1, false);
    ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
  }

  private void alternateToolStripMenuItem1_Click(object sender, EventArgs e)
  {
    List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
    int count = ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count;
    foreach (int num in selectedTreeRows)
    {
      if (num > 0 && num < count)
      {
        Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[num].Node;
        if (node != null)
          this.SetAlternateSchemaColumn(node.Key as CUiROMGridNodeInfo);
      }
    }
    ((ScrollableControl) this.m_targetOperationGrid).BeginUpdate();
    this.m_targetOperationGrid.UpdateRows(1, ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count - 1, false);
    ((ScrollableControl) this.m_targetOperationGrid).EndUpdate();
  }

  private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
  {
    bool flag = true;
    List<int> selectedTreeRows = this.m_targetOperationGrid.SelectedTreeRows;
    int count = ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count;
    foreach (int num in selectedTreeRows)
    {
      if (num > 0 && num < count)
      {
        Node node = ((C1FlexGridBase) this.m_targetOperationGrid).Rows[num].Node;
        if (node != null)
        {
          CUiROMGridNodeInfo key = node.Key as CUiROMGridNodeInfo;
          if (key.NodeType == CUiROMDataUtils.NodeType.SeamLocation || key.NodeType == CUiROMDataUtils.NodeType.WeldLocation)
          {
            if (key is CUiROMRoboticTargetOperationInfo && (key as CUiROMRoboticTargetOperationInfo).MatchedOperation != null)
            {
              flag = false;
              break;
            }
            if (key is CUiROMTargetInfo && (key as CUiROMTargetInfo).MatchedObject != null)
            {
              flag = false;
              break;
            }
          }
        }
      }
    }
    e.Cancel = flag;
  }

  private void preview_Click(object sender, EventArgs e) => this.RunMerge(true);

  private void ComputeWeldContainer()
  {
    TxBaseWeldOperation targetOperation = this.m_targetOperation as TxBaseWeldOperation;
    this.m_weldLocationContainer = (ITxObjectCollection) null;
    if (!TxBaseWeldOperation.op_Inequality(targetOperation, (ITxObject) null))
      return;
    TxOperationRoot operationRoot = TxApplication.ActiveDocument.OperationRoot;
    if (TxTcUtilities.IsTcAnyPlatform)
    {
      ITxObjectCollection collection = targetOperation.Collection;
      while (this.m_weldLocationContainer == null && collection != operationRoot)
      {
        if (collection is TxTcProcess)
          this.m_weldLocationContainer = collection;
        else
          collection = ((ITxObject) collection).Collection;
      }
    }
    else
      this.m_weldLocationContainer = (ITxObjectCollection) operationRoot;
  }

  protected virtual void Dispose(bool disposing)
  {
    if (disposing && this.components != null)
      this.components.Dispose();
    base.Dispose(disposing);
  }

  private void InitializeComponent()
  {
    this.components = (IContainer) new Container();
    ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (CUiROMMainForm));
    this.m_mainFormToolbar = new TxToolBar();
    this.m_selectOperationsButton = new TxToolBarButton();
    this.m_settingsButton = new TxToolBarButton();
    this.m_separator1 = new ToolBarButton();
    this.m_automaticMatchButton = new TxToolBarButton();
    this.m_matchButton = new TxToolBarButton();
    this.m_alternativeMatchButton = new TxToolBarButton();
    this.m_unMatchButton = new TxToolBarButton();
    this.m_deleteUnmatchedButton = new TxToolBarButton();
    this.m_separator2 = new ToolBarButton();
    this.m_addLocationsBeforeButton = new TxToolBarButton();
    this.m_addLocationsAfterButton = new TxToolBarButton();
    this.m_replaceEmptyTarget = new TxToolBarButton();
    this.m_emphasizePairButton = new TxToolBarButton();
    this.m_separator3 = new ToolBarButton();
    this.m_moveLocationsUpButton = new TxToolBarButton();
    this.m_moveLocationsDownButton = new TxToolBarButton();
    this.m_reverseButton = new TxToolBarButton();
    this.m_reorderButton = new TxToolBarButton();
    this.m_removeFromTargetButton = new TxToolBarButton();
    this.m_separator4 = new ToolBarButton();
    this.m_selectAllButton = new TxToolBarButton();
    this.m_unselectAllButton = new TxToolBarButton();
    this.m_executeButton = new TxButton();
    this.m_resetButton = new TxButton();
    this.m_closeButton = new TxButton();
    this.panel1 = new Panel();
    this.panel3 = new Panel();
    this.splitter1 = new Splitter();
    this.panel2 = new Panel();
    this.contextMenuStrip1 = new TxContextMenuStrip(this.components);
    this.defulatToolStripMenuItem = new TxToolStripMenuItem();
    this.defaultToolStripMenuItem = new TxToolStripMenuItem();
    this.alternateToolStripMenuItem1 = new TxToolStripMenuItem();
    this.m_previewButton = new TxButton();
    this.m_sourceOperationGrid = new CUiROMRoboticOperationGridWrapper();
    this.m_targetOperationGrid = new CUiROMRoboticOperationGridWrapper();
    this.panel1.SuspendLayout();
    this.panel3.SuspendLayout();
    this.panel2.SuspendLayout();
    ((Control) this.contextMenuStrip1).SuspendLayout();
    ((ISupportInitialize) this.m_sourceOperationGrid).BeginInit();
    ((ISupportInitialize) this.m_targetOperationGrid).BeginInit();
    ((Control) this).SuspendLayout();
    componentResourceManager.ApplyResources((object) this.m_mainFormToolbar, "m_mainFormToolbar");
    ((ToolBar) this.m_mainFormToolbar).Buttons.AddRange(new ToolBarButton[22]
    {
      (ToolBarButton) this.m_selectOperationsButton,
      (ToolBarButton) this.m_settingsButton,
      this.m_separator1,
      (ToolBarButton) this.m_automaticMatchButton,
      (ToolBarButton) this.m_matchButton,
      (ToolBarButton) this.m_alternativeMatchButton,
      (ToolBarButton) this.m_unMatchButton,
      (ToolBarButton) this.m_deleteUnmatchedButton,
      this.m_separator2,
      (ToolBarButton) this.m_addLocationsBeforeButton,
      (ToolBarButton) this.m_addLocationsAfterButton,
      (ToolBarButton) this.m_replaceEmptyTarget,
      (ToolBarButton) this.m_emphasizePairButton,
      this.m_separator3,
      (ToolBarButton) this.m_moveLocationsUpButton,
      (ToolBarButton) this.m_moveLocationsDownButton,
      (ToolBarButton) this.m_reverseButton,
      (ToolBarButton) this.m_reorderButton,
      (ToolBarButton) this.m_removeFromTargetButton,
      this.m_separator4,
      (ToolBarButton) this.m_selectAllButton,
      (ToolBarButton) this.m_unselectAllButton
    });
    ((ToolBar) this.m_mainFormToolbar).Divider = false;
    ((Control) this.m_mainFormToolbar).Name = "m_mainFormToolbar";
    ((ToolBar) this.m_mainFormToolbar).ButtonClick += new ToolBarButtonClickEventHandler(this.m_mainFormToolbar_ButtonClick);
    ((ToolBar) this.m_mainFormToolbar).Appearance = ToolBarAppearance.Flat;
    componentResourceManager.ApplyResources((object) this.m_selectOperationsButton, "m_selectOperationsButton");
    ((ToolBarButton) this.m_selectOperationsButton).Name = "m_selectOperationsButton";
    componentResourceManager.ApplyResources((object) this.m_settingsButton, "m_settingsButton");
    ((ToolBarButton) this.m_settingsButton).Name = "m_settingsButton";
    this.m_separator1.Name = "m_separator1";
    this.m_separator1.Style = ToolBarButtonStyle.Separator;
    componentResourceManager.ApplyResources((object) this.m_automaticMatchButton, "m_automaticMatchButton");
    ((ToolBarButton) this.m_automaticMatchButton).Name = "m_automaticMatchButton";
    componentResourceManager.ApplyResources((object) this.m_matchButton, "m_matchButton");
    ((ToolBarButton) this.m_matchButton).Name = "m_matchButton";
    componentResourceManager.ApplyResources((object) this.m_alternativeMatchButton, "m_alternativeMatchButton");
    ((ToolBarButton) this.m_alternativeMatchButton).Name = "m_alternativeMatchButton";
    componentResourceManager.ApplyResources((object) this.m_unMatchButton, "m_unMatchButton");
    ((ToolBarButton) this.m_unMatchButton).Name = "m_unMatchButton";
    componentResourceManager.ApplyResources((object) this.m_deleteUnmatchedButton, "m_deleteUnmatchedButton");
    ((ToolBarButton) this.m_deleteUnmatchedButton).Name = "m_deleteUnmatchedButton";
    this.m_separator2.Name = "m_separator2";
    this.m_separator2.Style = ToolBarButtonStyle.Separator;
    componentResourceManager.ApplyResources((object) this.m_addLocationsBeforeButton, "m_addLocationsBeforeButton");
    ((ToolBarButton) this.m_addLocationsBeforeButton).Name = "m_addLocationsBeforeButton";
    componentResourceManager.ApplyResources((object) this.m_addLocationsAfterButton, "m_addLocationsAfterButton");
    ((ToolBarButton) this.m_addLocationsAfterButton).Name = "m_addLocationsAfterButton";
    componentResourceManager.ApplyResources((object) this.m_replaceEmptyTarget, "m_replaceEmptyTarget");
    ((ToolBarButton) this.m_replaceEmptyTarget).Name = "m_replaceEmptyTarget";
    componentResourceManager.ApplyResources((object) this.m_emphasizePairButton, "m_emphasizePairButton");
    ((ToolBarButton) this.m_emphasizePairButton).Name = "m_emphasizePairButton";
    ((ToolBarButton) this.m_emphasizePairButton).Style = ToolBarButtonStyle.ToggleButton;
    this.m_separator3.Name = "m_separator3";
    this.m_separator3.Style = ToolBarButtonStyle.Separator;
    componentResourceManager.ApplyResources((object) this.m_moveLocationsUpButton, "m_moveLocationsUpButton");
    ((ToolBarButton) this.m_moveLocationsUpButton).Name = "m_moveLocationsUpButton";
    componentResourceManager.ApplyResources((object) this.m_moveLocationsDownButton, "m_moveLocationsDownButton");
    ((ToolBarButton) this.m_moveLocationsDownButton).Name = "m_moveLocationsDownButton";
    componentResourceManager.ApplyResources((object) this.m_reverseButton, "m_reverseButton");
    ((ToolBarButton) this.m_reverseButton).Name = "m_reverseButton";
    componentResourceManager.ApplyResources((object) this.m_reorderButton, "m_reorderButton");
    ((ToolBarButton) this.m_reorderButton).Name = "m_reorderButton";
    componentResourceManager.ApplyResources((object) this.m_removeFromTargetButton, "m_removeFromTargetButton");
    ((ToolBarButton) this.m_removeFromTargetButton).Name = "m_removeFromTargetButton";
    this.m_separator4.Name = "m_separator4";
    this.m_separator4.Style = ToolBarButtonStyle.Separator;
    componentResourceManager.ApplyResources((object) this.m_selectAllButton, "m_selectAllButton");
    ((ToolBarButton) this.m_selectAllButton).Name = "m_selectAllButton";
    componentResourceManager.ApplyResources((object) this.m_unselectAllButton, "m_unselectAllButton");
    ((ToolBarButton) this.m_unselectAllButton).Name = "m_unselectAllButton";
    this.m_selectOperationsButton.SetImage(TxImageManager.GetImageByKey("SelectOperations"));
    this.m_settingsButton.SetImage(TxImageManager.GetImageByKey("Settings"));
    this.m_automaticMatchButton.SetImage(TxImageManager.GetImageByKey("AutomaticMatchMerge"));
    this.m_matchButton.SetImage(TxImageManager.GetImageByKey("MatchMerge"));
    this.m_alternativeMatchButton.SetImage(TxImageManager.GetImageByKey("AlternativeMatchMerge"));
    this.m_unMatchButton.SetImage(TxImageManager.GetImageByKey("EraseMatchMerge"));
    this.m_deleteUnmatchedButton.SetImage(TxImageManager.GetImageByKey("DeleteUnmatchedMerge"));
    this.m_addLocationsBeforeButton.SetImage(TxImageManager.GetImageByKey("InsertLocationBeforeMerge"));
    this.m_addLocationsAfterButton.SetImage(TxImageManager.GetImageByKey("InsertLocationAfterMerge"));
    this.m_replaceEmptyTarget.SetImage(TxImageManager.GetImageByKey("ReplaceEmptyTargetMerge"));
    this.m_emphasizePairButton.SetImage(TxImageManager.GetImageByKey("EmphasizeSelectedPairsMerge"));
    this.m_moveLocationsUpButton.SetImage(TxImageManager.GetImageByKey("MoveUp"));
    this.m_moveLocationsDownButton.SetImage(TxImageManager.GetImageByKey("MoveDown"));
    this.m_reverseButton.SetImage(TxImageManager.GetImageByKey("ReverseMerge"));
    this.m_reorderButton.SetImage(TxImageManager.GetImageByKey("ReorderByMatchedLocationsMerge"));
    this.m_removeFromTargetButton.SetImage(TxImageManager.GetImageByKey("Delete"));
    this.m_selectAllButton.SetImage(TxImageManager.GetImageByKey("CheckAll"));
    this.m_unselectAllButton.SetImage(TxImageManager.GetImageByKey("UncheckAll"));
    ((ToolBarButton) this.m_selectOperationsButton).ImageIndex = 0;
    ((ToolBarButton) this.m_settingsButton).ImageIndex = 1;
    ((ToolBarButton) this.m_automaticMatchButton).ImageIndex = 2;
    ((ToolBarButton) this.m_matchButton).ImageIndex = 3;
    ((ToolBarButton) this.m_alternativeMatchButton).ImageIndex = 4;
    ((ToolBarButton) this.m_unMatchButton).ImageIndex = 5;
    ((ToolBarButton) this.m_deleteUnmatchedButton).ImageIndex = 6;
    ((ToolBarButton) this.m_addLocationsBeforeButton).ImageIndex = 7;
    ((ToolBarButton) this.m_addLocationsAfterButton).ImageIndex = 8;
    ((ToolBarButton) this.m_replaceEmptyTarget).ImageIndex = 9;
    ((ToolBarButton) this.m_emphasizePairButton).ImageIndex = 10;
    ((ToolBarButton) this.m_moveLocationsUpButton).ImageIndex = 11;
    ((ToolBarButton) this.m_moveLocationsDownButton).ImageIndex = 12;
    ((ToolBarButton) this.m_reverseButton).ImageIndex = 13;
    ((ToolBarButton) this.m_reorderButton).ImageIndex = 14;
    ((ToolBarButton) this.m_removeFromTargetButton).ImageIndex = 15;
    ((ToolBarButton) this.m_selectAllButton).ImageIndex = 16 /*0x10*/;
    ((ToolBarButton) this.m_unselectAllButton).ImageIndex = 17;
    this.m_mainFormToolbar.InitImages();
    componentResourceManager.ApplyResources((object) this.m_executeButton, "m_executeButton");
    ((Control) this.m_executeButton).Name = "m_executeButton";
    ((ButtonBase) this.m_executeButton).UseVisualStyleBackColor = true;
    ((Control) this.m_executeButton).Click += new EventHandler(this.m_executeButton_Click);
    componentResourceManager.ApplyResources((object) this.m_resetButton, "m_resetButton");
    ((Control) this.m_resetButton).Name = "m_resetButton";
    ((ButtonBase) this.m_resetButton).UseVisualStyleBackColor = true;
    ((Control) this.m_resetButton).Click += new EventHandler(this.m_resetButton_Click);
    componentResourceManager.ApplyResources((object) this.m_closeButton, "m_closeButton");
    ((Control) this.m_closeButton).Name = "m_closeButton";
    ((ButtonBase) this.m_closeButton).UseVisualStyleBackColor = true;
    ((Control) this.m_closeButton).Click += new EventHandler(this.m_closeButton_Click);
    componentResourceManager.ApplyResources((object) this.panel1, "panel1");
    this.panel1.Controls.Add((Control) this.panel3);
    this.panel1.Controls.Add((Control) this.splitter1);
    this.panel1.Controls.Add((Control) this.panel2);
    this.panel1.Name = "panel1";
    this.panel3.Controls.Add((Control) this.m_sourceOperationGrid);
    componentResourceManager.ApplyResources((object) this.panel3, "panel3");
    this.panel3.Name = "panel3";
    componentResourceManager.ApplyResources((object) this.splitter1, "splitter1");
    this.splitter1.Name = "splitter1";
    this.splitter1.TabStop = false;
    this.panel2.Controls.Add((Control) this.m_targetOperationGrid);
    componentResourceManager.ApplyResources((object) this.panel2, "panel2");
    this.panel2.Name = "panel2";
    ((ToolStrip) this.contextMenuStrip1).Items.AddRange(new ToolStripItem[1]
    {
      (ToolStripItem) this.defulatToolStripMenuItem
    });
    ((Control) this.contextMenuStrip1).Name = "contextMenuStrip1";
    ((ToolStrip) this.contextMenuStrip1).RenderMode = ToolStripRenderMode.System;
    componentResourceManager.ApplyResources((object) this.contextMenuStrip1, "contextMenuStrip1");
    ((ToolStripDropDown) this.contextMenuStrip1).Opening += new CancelEventHandler(this.contextMenuStrip1_Opening);
    ((ToolStripDropDownItem) this.defulatToolStripMenuItem).DropDownItems.AddRange(new ToolStripItem[2]
    {
      (ToolStripItem) this.defaultToolStripMenuItem,
      (ToolStripItem) this.alternateToolStripMenuItem1
    });
    ((ToolStripItem) this.defulatToolStripMenuItem).Name = "defulatToolStripMenuItem";
    componentResourceManager.ApplyResources((object) this.defulatToolStripMenuItem, "defulatToolStripMenuItem");
    ((ToolStripItem) this.defaultToolStripMenuItem).Name = "defaultToolStripMenuItem";
    componentResourceManager.ApplyResources((object) this.defaultToolStripMenuItem, "defaultToolStripMenuItem");
    ((ToolStripItem) this.defaultToolStripMenuItem).Click += new EventHandler(this.defaultToolStripMenuItem_Click);
    ((ToolStripItem) this.alternateToolStripMenuItem1).Name = "alternateToolStripMenuItem1";
    componentResourceManager.ApplyResources((object) this.alternateToolStripMenuItem1, "alternateToolStripMenuItem1");
    ((ToolStripItem) this.alternateToolStripMenuItem1).Click += new EventHandler(this.alternateToolStripMenuItem1_Click);
    componentResourceManager.ApplyResources((object) this.m_previewButton, "m_previewButton");
    ((Control) this.m_previewButton).Name = "m_previewButton";
    ((ButtonBase) this.m_previewButton).UseVisualStyleBackColor = true;
    ((Control) this.m_previewButton).Click += new EventHandler(this.preview_Click);
    ((C1FlexGridBase) this.m_sourceOperationGrid).AllowDragging = (AllowDraggingEnum) 0;
    ((C1FlexGridBase) this.m_sourceOperationGrid).AllowSorting = (AllowSortingEnum) 0;
    componentResourceManager.ApplyResources((object) this.m_sourceOperationGrid, "m_sourceOperationGrid");
    ((C1FlexGridBase) this.m_sourceOperationGrid).DrawMode = (DrawModeEnum) 1;
    ((C1FlexGridBase) this.m_sourceOperationGrid).EmptyAsNull = false;
    ((C1FlexGridBase) this.m_sourceOperationGrid).ExtendLastCol = true;
    ((C1FlexGridBase) this.m_sourceOperationGrid).FocusRect = (FocusRectEnum) 0;
    this.m_sourceOperationGrid.LinearDigitsAfterDecimalPoint = 2;
    this.m_sourceOperationGrid.LinearMultiplier = 1.0;
    this.m_sourceOperationGrid.ManualSelection = CUiROMDataUtils.ManualSelection.CtrlShift;
    ((Control) this.m_sourceOperationGrid).Name = "m_sourceOperationGrid";
    ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).Count = 1;
    ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).DefaultSize = 19;
    ((RowColCollection) ((C1FlexGridBase) this.m_sourceOperationGrid).Rows).MinSize = 18;
    ((C1FlexGridBase) this.m_sourceOperationGrid).SelectionMode = (SelectionModeEnum) 3;
    ((C1FlexGridBase) this.m_sourceOperationGrid).StyleInfo = componentResourceManager.GetString("m_sourceOperationGrid.StyleInfo");
    ((C1FlexGridBase) this.m_sourceOperationGrid).Tree.Column = 0;
    ((C1FlexGridBase) this.m_sourceOperationGrid).Tree.Style = (TreeStyleFlags) 11;
    ((C1FlexGridBase) this.m_targetOperationGrid).AllowDragging = (AllowDraggingEnum) 0;
    ((C1FlexGridBase) this.m_targetOperationGrid).AllowSorting = (AllowSortingEnum) 0;
    componentResourceManager.ApplyResources((object) this.m_targetOperationGrid, "m_targetOperationGrid");
    ((Control) this.m_targetOperationGrid).ContextMenuStrip = (ContextMenuStrip) this.contextMenuStrip1;
    ((C1FlexGridBase) this.m_targetOperationGrid).DrawMode = (DrawModeEnum) 1;
    ((C1FlexGridBase) this.m_targetOperationGrid).EmptyAsNull = false;
    ((C1FlexGridBase) this.m_targetOperationGrid).ExtendLastCol = true;
    ((C1FlexGridBase) this.m_targetOperationGrid).FocusRect = (FocusRectEnum) 0;
    ((C1FlexGridBase) this.m_targetOperationGrid).HighLight = (HighLightEnum) 2;
    this.m_targetOperationGrid.LinearDigitsAfterDecimalPoint = 2;
    this.m_targetOperationGrid.LinearMultiplier = 1.0;
    this.m_targetOperationGrid.ManualSelection = CUiROMDataUtils.ManualSelection.CtrlShift;
    ((Control) this.m_targetOperationGrid).Name = "m_targetOperationGrid";
    ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).Count = 1;
    ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).DefaultSize = 19;
    ((RowColCollection) ((C1FlexGridBase) this.m_targetOperationGrid).Rows).MinSize = 18;
    ((C1FlexGridBase) this.m_targetOperationGrid).SelectionMode = (SelectionModeEnum) 1;
    ((C1FlexGridBase) this.m_targetOperationGrid).StyleInfo = componentResourceManager.GetString("m_targetOperationGrid.StyleInfo");
    ((C1FlexGridBase) this.m_targetOperationGrid).Tree.Column = 0;
    ((C1FlexGridBase) this.m_targetOperationGrid).Tree.Style = (TreeStyleFlags) 11;
    componentResourceManager.ApplyResources((object) this, "$this");
    ((ContainerControl) this).AutoScaleMode = AutoScaleMode.Font;
    ((Control) this).Controls.Add((Control) this.m_previewButton);
    ((Control) this).Controls.Add((Control) this.panel1);
    ((Control) this).Controls.Add((Control) this.m_closeButton);
    ((Control) this).Controls.Add((Control) this.m_mainFormToolbar);
    ((Control) this).Controls.Add((Control) this.m_resetButton);
    ((Control) this).Controls.Add((Control) this.m_executeButton);
    ((Form) this).MaximizeBox = false;
    ((Form) this).MinimizeBox = false;
    ((Control) this).Name = nameof (CUiROMMainForm);
    ((Form) this).SizeGripStyle = SizeGripStyle.Hide;
    this.panel1.ResumeLayout(false);
    this.panel3.ResumeLayout(false);
    this.panel2.ResumeLayout(false);
    ((Control) this.contextMenuStrip1).ResumeLayout(false);
    ((ISupportInitialize) this.m_sourceOperationGrid).EndInit();
    ((ISupportInitialize) this.m_targetOperationGrid).EndInit();
    ((Control) this).ResumeLayout(false);
  }

  private enum MainToolbarButtons
  {
    SelectOperations,
    Settings,
    Separator1,
    AutomaticMatch,
    Match,
    AlternativeMatch,
    UnMatch,
    DeleteUnmatched,
    Separator2,
    AddLocationsBefore,
    AddLocationsAfter,
    ReplaceEmptyTarget,
    EmphasizePair,
    Separator3,
    MoveLocationsUp,
    MoveLocationsDown,
    Reverse,
    Reorder,
    RemoveFromTarget,
    Separator4,
    SelectAll,
    UnselectAll,
  }
}
